-
Notifications
You must be signed in to change notification settings - Fork 0
34 lines (30 loc) · 1023 Bytes
/
Copy pathcommitlint.yml
File metadata and controls
34 lines (30 loc) · 1023 Bytes
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
name: Commitlint
on:
pull_request:
branches: [main]
permissions:
contents: read
jobs:
commitlint:
name: Validate commit messages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
# Reuses .githooks/commit-msg so there is a single source of truth for
# the Conventional Commits rule — no Node/commitlint install required,
# so this works the same for every language this template is used for.
- name: Check commit messages
run: |
set -e
chmod +x .githooks/commit-msg
FAILED=0
for sha in $(git rev-list "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"); do
git log -1 --format=%B "$sha" > /tmp/commit-msg
if ! .githooks/commit-msg /tmp/commit-msg; then
echo "::error::Commit $sha does not follow Conventional Commits"
FAILED=1
fi
done
exit "$FAILED"