Skip to content

Commit

Permalink
more types and scopes accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
PeSme committed Nov 13, 2023
1 parent 4a67311 commit 7d8684d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions orbs/shared/commands/skip_on_chore_commit.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
description: >
If the first commit of the branch (where branch diverged from main/master)
starts with 'chore:' all the following steps of the job will be skipped
and the job finishes as succeeded
starts with 'chore', 'ci' or 'docs' all the following steps of the job will be skipped
and the job finishes as succeeded.
steps:
- checkout
- run:
name: Evaluate commit type
command: |
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | cut -f 4 -d /)
COMMIT_MESSAGE=$(git log $DEFAULT_BRANCH..$CIRCLE_SHA1 --format=%s | tail -1)
echo "First commit: $COMMIT_MESSAGE"
if [[ "${COMMIT_MESSAGE%:*}" == "chore" ]]; then
echo "Skipping job for '${COMMIT_MESSAGE%:*}' commit type."
circleci step halt
COMMIT_MESSAGE=$(git log "$DEFAULT_BRANCH..$CIRCLE_SHA1" --format=%s | tail -1)
COMMIT_PREFIX="${COMMIT_MESSAGE%%:*}"
COMMIT_TYPE="${COMMIT_PREFIX%%(*}"
echo "Identified commit type '$COMMIT_TYPE' in the first commit message '$COMMIT_MESSAGE'"
if [[ $COMMIT_TYPE =~ ^(chore|ci|docs)$ ]]; then
echo "Skipping job for '$COMMIT_TYPE' commit type."
circleci-agent step halt
else
echo "Running job for '${COMMIT_MESSAGE%:*}' commit type."
echo "Running job for '$COMMIT_TYPE' commit type."
fi

0 comments on commit 7d8684d

Please sign in to comment.