Skip to content

Commit d4974de

Browse files
committed
ci: Lint PR titles with Conventional Commits standard
1 parent 8f860b9 commit d4974de

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/semantic-pr.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Semantic Pull Request
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
semantic-pr:
12+
name: Validate PR title follows conventional commit format
13+
runs-on: ubuntu-latest
14+
# TODO: Remove this once we commit to conventional commits
15+
continue-on-error: true
16+
17+
steps:
18+
- name: Validate PR title
19+
id: lint_pr_title
20+
uses: amannn/[email protected]
21+
with:
22+
# Allow standard conventional commit types
23+
types: |
24+
fix
25+
feat
26+
docs
27+
style
28+
refactor
29+
perf
30+
test
31+
chore
32+
ci
33+
build
34+
# TODO: Remove this once we've decided on scopes
35+
requireScope: false
36+
# Skip validation for certain labels if needed
37+
ignoreLabels: |
38+
skip-commit-format
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Comment on PR if validation fails
43+
if: steps.lint_pr_title.outputs.error_message != null
44+
uses: actions/github-script@v7
45+
with:
46+
script: |
47+
github.rest.issues.createComment({
48+
issue_number: context.issue.number,
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
body: `⚠️ **Semantic PR Check Failed**
52+
53+
**Error Details:**
54+
\`\`\`
55+
${{ steps.lint_pr_title.outputs.error_message }}
56+
\`\`\`
57+
58+
**Required Format:**
59+
\`\`\`
60+
<type>: <description>
61+
\`\`\`
62+
63+
**Allowed types:** fix, feat, docs, style, refactor, perf, test, chore, ci, build
64+
65+
**Examples:**
66+
- \`feat: add user authentication system\`
67+
- \`fix: resolve memory leak in worker pool\`
68+
- \`docs: update API documentation\`
69+
- \`test: add integration tests for auth flow\`
70+
71+
This is currently a **warning only** and won't block your PR from being merged.`
72+
})

0 commit comments

Comments
 (0)