-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
8 deletions.
There are no files selected for viewing
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
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 |