-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (35 loc) · 1.18 KB
/
Copy pathcommit-message-check.yml
File metadata and controls
35 lines (35 loc) · 1.18 KB
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
# Shells out to .husky/commit-msg (not a reimplemented regex) so local and CI
# rules can't drift: `sh .husky/commit-msg <message-file>`, exit code = verdict.
name: Commit Message Check
on:
pull_request:
concurrency:
group: commit-message-check-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
run-commit-message-check:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Validate commit subjects
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -uo pipefail
MERGE_BASE=$(git merge-base "$BASE_SHA" "$HEAD_SHA")
FAILED=0
for SHA in $(git rev-list --no-merges "$MERGE_BASE..$HEAD_SHA"); do
git log -1 --format=%B "$SHA" > "$RUNNER_TEMP/msg.txt"
if ! sh .husky/commit-msg "$RUNNER_TEMP/msg.txt"; then
echo "::error::$SHA — invalid commit subject (see log for the rule violated)"
FAILED=1
fi
done
exit $FAILED