Skip to content

Commit bfbc420

Browse files
committed
ci: enforce conventional commits on pushes to main
1 parent 10d345f commit bfbc420

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13+
commit-lint:
14+
name: Commit Lint
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'push'
17+
steps:
18+
- uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
- name: Check conventional commits
22+
run: |
23+
PATTERN='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .+'
24+
FAILED=0
25+
for sha in $(git log --format='%H' origin/main~1..HEAD 2>/dev/null || git log --format='%H' -1); do
26+
msg=$(git log --format='%s' -1 "$sha")
27+
if ! echo "$msg" | grep -qE "$PATTERN"; then
28+
echo "Bad commit message: $msg"
29+
FAILED=1
30+
fi
31+
done
32+
if [ "$FAILED" = "1" ]; then
33+
echo "Commit messages must follow conventional commits: type(scope): subject"
34+
exit 1
35+
fi
36+
1337
check:
1438
name: Check
1539
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)