Skip to content

Commit e11d2f3

Browse files
committed
move skip logic into script
1 parent 2e12714 commit e11d2f3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.github/scripts/commit-checker.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ git checkout -q $1
66
# Set variables
77
BASE_BRANCH=$2
88
msg_regex='(AAA|BBB|CCC)\-[0-9]+'
9+
skip_regex='\[SKIP JIRA\]'
910

1011
# Initialize invalidCommit as false, will be set to true by any invalid commits
1112
invalidCommit=false
@@ -23,7 +24,16 @@ BRANCH_COMMITS=$(git rev-list ${BRANCH_MERGE_BASE}..HEAD)
2324

2425
# Check every commit message since ancestor for regex match
2526
for commit in $BRANCH_COMMITS; do
26-
if git log --max-count=1 --format=%B $commit | tr '[a-z]' '[A-Z]' | grep -iqE "$msg_regex"; then
27+
CURRENT_COMMIT_MSG=$(git log --max-count=1 --format=%B $commit | tr '[a-z]' '[A-Z]')
28+
29+
if echo $COMMIT_MSG_UPPER | grep -iqE "$skip_regex"; then
30+
echo "************"
31+
echo "[skip jira] detected, skipping commit linting"
32+
echo "************"
33+
exit 0
34+
fi
35+
36+
if echo $COMMIT_MSG_UPPER | grep -iqE "$msg_regex"; then
2737
: #If commit matches regex, commit is valid, do nothing
2838
else
2939
# If commit doesn't match regex, commit isn't valid, print commit info

.github/workflows/commit-checker.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on: [pull_request]
55

66
jobs:
77
commit-checker:
8-
if: ${{ !contains(github.event.head_commit.message, '[skip jira]') }}
98
runs-on: ubuntu-latest
109

1110
steps:

0 commit comments

Comments
 (0)