-
-
Notifications
You must be signed in to change notification settings - Fork 5
37 lines (36 loc) · 1.34 KB
/
check-commit.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
name: Check Commit
on:
push:
tags:
branches:
- master
pull_request:
jobs:
build:
name: Check Commit
runs-on: ubuntu-latest
steps:
- name: Verify commit message [push]
id: verify_commit_message
run: |
if [[ ! "${{ github.event.head_commit.message }}" =~ ^(feat\(*[a-z0-9#]*\)*:)|(fix\(*[a-z0-9#]*\)*:)|(docs\(*[a-z0-9#]*\)*:)|(build\(*[a-z0-9#]*\)*:)|(refactor\(*[a-z0-9#]*\)*:)|(misc\(*[a-z0-9#]*\)*:).* ]]; then
echo "Invalid commit message: "
echo "${{ github.event.head_commit.message }}"
exit 1
fi
if: ${{ github.event_name == 'push' }}
- name: Verify commit message [pr] - get repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
if: ${{ github.event_name == 'pull_request' }}
- name: Verify commit message [pr] - verify
id: get_head_commit_message
run: |
export commit=$(git show -s --format=%s)
if [[ ! "$commit" =~ ^(feat\(*[a-z0-9#]*\)*:)|(fix\(*[a-z0-9#]*\)*:)|(docs\(*[a-z0-9#]*\)*:)|(build\(*[a-z0-9#]*\)*:)|(refactor\(*[a-z0-9#]*\)*:)|(misc\(*[a-z0-9#]*\)*:).* ]]; then
echo "Invalid commit message: "
echo "$commit"
exit 1
fi
if: ${{ github.event_name == 'pull_request' }}