Skip to content

Commit bd5f322

Browse files
authored
ci: enforce pr title format via a github actions workflow (#538)
1 parent 6369524 commit bd5f322

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/pr-title.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: PR Title Convention
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
branches: [main]
7+
8+
permissions:
9+
pull-requests: read
10+
11+
jobs:
12+
check-title:
13+
name: Validate PR title
14+
runs-on: ubuntu-22.04
15+
timeout-minutes: 1
16+
steps:
17+
- name: Check conventional commit format
18+
env:
19+
PR_TITLE: ${{ github.event.pull_request.title }}
20+
run: |
21+
# Allowed conventional commit types
22+
TYPES="feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert"
23+
24+
# Pattern: type(optional-scope): description
25+
# OR: type!: description (breaking change)
26+
PATTERN="^($TYPES)(\(.+\))?\!?: .+"
27+
28+
if echo "$PR_TITLE" | grep -qP "$PATTERN"; then
29+
echo "PR title is valid: $PR_TITLE"
30+
else
31+
echo "::error::PR title does not follow Conventional Commits."
32+
echo ""
33+
echo "Got: $PR_TITLE"
34+
echo ""
35+
echo "Expected: <type>[optional scope]: <description>"
36+
echo ""
37+
echo "Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
38+
echo "Read more: https://www.conventionalcommits.org/en/v1.0.0/"
39+
echo ""
40+
echo "Examples:"
41+
echo " feat: add new optimization algorithm"
42+
echo " fix: resolve memory leak in model loading"
43+
echo " ci(pruna): pin transformers version"
44+
echo ""
45+
exit 1
46+
fi

0 commit comments

Comments
 (0)