-
Notifications
You must be signed in to change notification settings - Fork 11
37 lines (36 loc) · 1.06 KB
/
merge-rules.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: 'Pull Request Check'
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Commit Message
run: |
nlines=-1
for (( N=1; N<=${{github.event.pull_request.commits}}; N++ ))
do
prev_lines=$(($nlines+1))
nlines=0
while IFS= read -r line
do
nlines=$((nlines+1))
if (( $nlines == $prev_lines+1 )); then
if ! [[ "$line" =~ ^\[#[0-9]+\]\ .+$|^\[NO-ISSUE\]\ .+$ ]]; then
echo "[ commit $N ]: Commit message should begin with [#nnn] or [NO-ISSUE], followed by a space."
echo "but it is: $line"
exit 1
fi
fi
done <<< $(git log --format=%B -n $N ${{github.event.pull_request.head.sha}})
done