Last active
December 24, 2018 02:13
-
-
Save at-daonguyen/af317a2c41c6336810ab48c0d90f323d to your computer and use it in GitHub Desktop.
Workaround $CIRCLE_PR_NUMBER for CircleCI
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
#!/bin/bash | |
if [[ -z "$CIRCLE_PR_NUMBER" ]]; then | |
if [[ -z "$CI_PULL_REQUEST" ]]; then | |
URL="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH" | |
RESULT="`curl -X GET -u $GITHUB_ACCESS_TOKEN:x-oauth-basic $URL | jq ".[0].url"`" | |
[[ "$RESULT" == 'null' ]] && CI_PULL_REQUEST='' || CI_PULL_REQUEST="${RESULT//\"}" | |
fi | |
CIRCLE_PR_NUMBER="$(basename "$CI_PULL_REQUEST")" | |
fi | |
echo "$CIRCLE_PR_NUMBER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment