Skip to content

Commit

Permalink
OCM-2369 | fix: update check commit format workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranRoche committed Jul 3, 2023
1 parent 99aa28b commit 8bb84ff
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/check-commit-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,28 @@
name: 'Validate Commit Messages'
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
pull_request_target:
types:
- opened
- edited
- reopened
- synchronize
branches:
- main

jobs:
parse-commit-messages:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Validate Commit Message(s)
run: |
IFS=$'\n' commit_messages=($(git log --pretty=format:"%s" HEAD...${{ github.event.pull_request.base.sha }}))
for message in "${commit_messages[@]}"
do
echo "validating $message"
if ! echo "$message" | grep -qE "^[A-Z]+-[0-9]+ \| (feat|fix|docs|style|refactor|test|chore|build|ci|perf) : .*$"; then
echo "Invalid commit message format. Expected format: JIRA_TICKET | TYPE : MESSAGE"
if ! echo "$message" | grep -qE "^[A-Z]+-[0-9]+ \| (feat|fix|docs|style|refactor|test|chore|build|ci|perf): .*$"; then
echo "Invalid commit message format. Expected format: JIRA_TICKET | TYPE: MESSAGE"
exit 1
fi
done

0 comments on commit 8bb84ff

Please sign in to comment.