Created
February 27, 2021 06:19
-
-
Save knapo/a047d34aef6ce434bc75197455064a9e to your computer and use it in GitHub Desktop.
Skip semaphore job on certain github PR labels
This file contains 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
jobs: | |
- name: Run my job | |
commands: | |
# Get PR labels from github api | |
- > | |
if [ ! -z "$SEMAPHORE_GIT_PR_NUMBER" ]; | |
then | |
export PR_DETAILS=$(curl -fsS -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/ORG_NAME/REPO_NAME/pulls/$SEMAPHORE_GIT_PR_NUMBER); | |
export PR_LABELS=$(echo $PR_DETAILS | tr '\r\n' ' ' | jq '.labels[] | .name'); | |
fi | |
- echo $PR_LABELS | |
# Run job unless PR contains specific labels contains skip/me | |
- > | |
if [[ $PR_LABELS =~ "skip/me" ]]; | |
then | |
echo "Skip job because the PR is labelled with skip/me"; | |
else | |
echo "Run my job"; | |
test | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment