-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-2369 | feat: Github Action for checking commit format
- Loading branch information
1 parent
de2ea81
commit 332a787
Showing
1 changed file
with
38 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# following the contribution guide this check enforces the commit format | ||
# [JIRA-TICKET] | [TYPE] : <MESSAGE> | ||
name: 'Validate Commit Messages' | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- synchronize | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- synchronize | ||
|
||
jobs: | ||
parse-commit-messages: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- 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" | ||
exit 1 | ||
fi | ||
done |