Skip to content

Commit 82a3a8c

Browse files
committed
ci: add PR title check for conventional commits
Add GitHub workflow that validates PR titles follow conventional commit format since we squash PRs and use the title as the commit message. The check validates: - PR title follows format: type(scope)?: description - Allowed types: feat, fix, chore, docs, style, refactor, perf, test, build, ci, revert, deps - Breaking changes can be indicated with '!' (e.g., feat!: breaking change) - Subject should start with lowercase - Scope is optional This ensures consistent commit history and proper semantic versioning when PRs are squashed and merged.
1 parent b9aeacd commit 82a3a8c

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: PR Title Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
jobs:
8+
check-pr-title:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check PR title follows Conventional Commits
12+
uses: amannn/action-semantic-pull-request@v5
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
with:
16+
# Configure which types are allowed
17+
types: |
18+
feat
19+
fix
20+
chore
21+
docs
22+
style
23+
refactor
24+
perf
25+
test
26+
build
27+
ci
28+
revert
29+
deps
30+
# Require a scope (optional - set to false if scope is not required)
31+
requireScope: false
32+
# Configure which scopes are allowed (optional)
33+
# scopes: |
34+
# core
35+
# api
36+
# cli
37+
# If the PR title should have a subject (default: true)
38+
subjectPattern: ^(?![A-Z]).+$
39+
subjectPatternError: |
40+
The subject "{subject}" found in the pull request title "{title}"
41+
didn't match the configured pattern. Please ensure that the subject
42+
doesn't start with an uppercase character.
43+
# Validate the entire PR title against a regex
44+
# This ensures format is: type(scope)?: description
45+
# Or with breaking change: type(scope)!: description
46+
headerPattern: '^(\w+)(\(\w+\))?!?: .+$'
47+
headerPatternCorrespondence: type, scope, subject

0 commit comments

Comments
 (0)