Created
March 21, 2020 00:30
-
-
Save tonglil/54ca9ff509a507864f5ed5f4d9df9787 to your computer and use it in GitHub Desktop.
Write to Github commit status from Drone 1.x with curl using .netrc credentials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://developer.github.com/v3/repos/statuses/ | |
if [ "${VERBOSE:-false}" = "true" ]; then | |
set -x | |
fi | |
apk add --no-cache curl | |
cat ~/.netrc | sed "s/github.com/api.github.com/" >> ~/.netrc | |
cat << EOF > ./data.json | |
{ | |
"state": "$CI_BUILD_STATUS", | |
"context": "drone/$CI_BUILD_EVENT/$DRONE_STAGE_NAME", | |
"description": "Steps failing: $DRONE_FAILED_STEPS", | |
"target_url": "$DRONE_BUILD_LINK/$DRONE_STAGE_NUMBER/$DRONE_STEP_NUMBER" | |
} | |
EOF | |
if [ "${VERBOSE:-false}" = "true" ]; then | |
cat ./data.json | |
fi | |
curl -n -s "https://api.github.com/repos/$CI_REPO/statuses/$CI_COMMIT_SHA" \ | |
-H "Content-Type: application/json" \ | |
-X POST \ | |
-d @data.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment