Skip to content

Instantly share code, notes, and snippets.

@knapo
Created February 27, 2021 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knapo/a047d34aef6ce434bc75197455064a9e to your computer and use it in GitHub Desktop.
Save knapo/a047d34aef6ce434bc75197455064a9e to your computer and use it in GitHub Desktop.
Skip semaphore job on certain github PR labels
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