Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/scripts/commit-checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ git checkout -q $1
# Set variables
BASE_BRANCH=$2
msg_regex='(AAA|BBB|CCC)\-[0-9]+'
skip_regex='\[SKIP JIRA\]'

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

# Check every commit message since ancestor for regex match
for commit in $BRANCH_COMMITS; do
if git log --max-count=1 --format=%B $commit | tr '[a-z]' '[A-Z]' | grep -iqE "$msg_regex"; then
CURRENT_COMMIT_MSG=$(git log --max-count=1 --format=%B $commit | tr '[a-z]' '[A-Z]')

if echo $COMMIT_MSG_UPPER | grep -iqE "$skip_regex"; then
echo "************"
echo "[skip jira] detected, skipping commit linting"
echo "************"
exit 0
fi

if echo $COMMIT_MSG_UPPER | grep -iqE "$msg_regex"; then
: #If commit matches regex, commit is valid, do nothing
else
# If commit doesn't match regex, commit isn't valid, print commit info
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/commit-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on: [pull_request]

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

steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# gh-actions-playground

test 2
test 23