Skip to content

Commit af7b144

Browse files
machado144claude
andcommitted
ci: add PR title conventional commit validation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5ce5028 commit af7b144

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/pr-title.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: PR Title
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
branches:
7+
- main
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Validate PR title follows Conventional Commits
14+
run: |
15+
TITLE="${{ github.event.pull_request.title }}"
16+
if ! echo "$TITLE" | grep -qE "^(feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(.+\))?(!)?: .+"; then
17+
echo "::error::PR title must follow Conventional Commits format"
18+
echo ""
19+
echo "Expected: <type>[optional scope][!]: <description>"
20+
echo ""
21+
echo "Examples:"
22+
echo " feat: add new feature"
23+
echo " fix(api): resolve null pointer"
24+
echo " feat!: breaking change"
25+
echo ""
26+
echo "Types: feat, fix, docs, style, refactor, test, chore, build, ci, perf, revert"
27+
exit 1
28+
fi
29+
echo "PR title is valid: $TITLE"

0 commit comments

Comments
 (0)