Skip to content

Commit c8431a4

Browse files
feat: add PR title semantic check workflow
1 parent 7842778 commit c8431a4

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: PR Title Semantic Check
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
types: [opened, edited, reopened, synchronize, ready_for_review]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
semantic-pr-title:
13+
name: Validate PR title (Conventional Commits)
14+
runs-on: self-hosted
15+
steps:
16+
- name: Check PR title format
17+
shell: bash
18+
env:
19+
PR_TITLE: ${{ github.event.pull_request.title }}
20+
run: |
21+
set -euo pipefail
22+
23+
# Allowed: type(scope): subject
24+
# Also allowed: type!: subject or type(scope)!: subject
25+
pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9._/-]+\))?(!)?: .+$'
26+
27+
if [[ "$PR_TITLE" =~ $pattern ]]; then
28+
echo "✅ PR title is semantic: $PR_TITLE"
29+
exit 0
30+
fi
31+
32+
echo "❌ PR title is not semantic: $PR_TITLE"
33+
echo ""
34+
echo "Expected Conventional Commits format:"
35+
echo " type(scope): short description"
36+
echo " type: short description"
37+
echo " type!: breaking change description"
38+
echo ""
39+
echo "Allowed types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test"
40+
echo "Examples:"
41+
echo " feat(workflow): validate PR title format"
42+
echo " fix: handle empty release metadata"
43+
echo " refactor(ci)!: drop legacy publish path"
44+
exit 1

0 commit comments

Comments
 (0)