-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 1.46 KB
/
commit-messages.yml
File metadata and controls
53 lines (46 loc) · 1.46 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Conventional Commits
on:
push:
tags-ignore:
- "v*"
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: read
jobs:
commit-subjects:
name: Validate commit messages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Resolve commit range
id: commit_range
run: |
set -euo pipefail
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
range="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
else
before_sha="${{ github.event.before }}"
after_sha="${GITHUB_SHA}"
if [ "${before_sha}" = "0000000000000000000000000000000000000000" ]; then
if git rev-parse "${after_sha}^" >/dev/null 2>&1; then
range="${after_sha}^..${after_sha}"
else
range="${after_sha}..${after_sha}"
fi
else
range="${before_sha}..${after_sha}"
fi
fi
echo "range=${range}" >> "$GITHUB_OUTPUT"
echo "Using commit range: ${range}"
- name: Check commit subjects in range
run: |
python scripts/check_commit_message.py --range "${{ steps.commit_range.outputs.range }}"