-
Notifications
You must be signed in to change notification settings - Fork 22
38 lines (36 loc) · 1.11 KB
/
check-commit-format.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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