Skip to content

Commit 7d8684d

Browse files
committed
more types and scopes accepted
1 parent 4a67311 commit 7d8684d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
description: >
22
If the first commit of the branch (where branch diverged from main/master)
3-
starts with 'chore:' all the following steps of the job will be skipped
4-
and the job finishes as succeeded
3+
starts with 'chore', 'ci' or 'docs' all the following steps of the job will be skipped
4+
and the job finishes as succeeded.
55
steps:
66
- checkout
77
- run:
88
name: Evaluate commit type
99
command: |
1010
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | cut -f 4 -d /)
11-
COMMIT_MESSAGE=$(git log $DEFAULT_BRANCH..$CIRCLE_SHA1 --format=%s | tail -1)
12-
echo "First commit: $COMMIT_MESSAGE"
13-
if [[ "${COMMIT_MESSAGE%:*}" == "chore" ]]; then
14-
echo "Skipping job for '${COMMIT_MESSAGE%:*}' commit type."
15-
circleci step halt
11+
COMMIT_MESSAGE=$(git log "$DEFAULT_BRANCH..$CIRCLE_SHA1" --format=%s | tail -1)
12+
COMMIT_PREFIX="${COMMIT_MESSAGE%%:*}"
13+
COMMIT_TYPE="${COMMIT_PREFIX%%(*}"
14+
echo "Identified commit type '$COMMIT_TYPE' in the first commit message '$COMMIT_MESSAGE'"
15+
if [[ $COMMIT_TYPE =~ ^(chore|ci|docs)$ ]]; then
16+
echo "Skipping job for '$COMMIT_TYPE' commit type."
17+
circleci-agent step halt
1618
else
17-
echo "Running job for '${COMMIT_MESSAGE%:*}' commit type."
19+
echo "Running job for '$COMMIT_TYPE' commit type."
1820
fi

0 commit comments

Comments
 (0)