Skip to content

Commit 970796b

Browse files
committed
docs: add PR title guidelines and workflow to enforce conventional commits
1 parent 3c50434 commit 970796b

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.github/workflows/pr-title.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: PR Title Validation
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
validate-title:
9+
if: |
10+
github.event.pull_request.user.login != 'actions-user' &&
11+
github.event.pull_request.user.login != 'opencode' &&
12+
github.event.pull_request.user.login != 'rekram1-node' &&
13+
github.event.pull_request.user.login != 'thdxr' &&
14+
github.event.pull_request.user.login != 'kommander' &&
15+
github.event.pull_request.user.login != 'jayair' &&
16+
github.event.pull_request.user.login != 'fwang' &&
17+
github.event.pull_request.user.login != 'adamdotdevin' &&
18+
github.event.pull_request.user.login != 'iamdavidhill' &&
19+
github.event.pull_request.user.login != 'opencode-agent[bot]'
20+
runs-on: ubuntu-latest
21+
permissions:
22+
pull-requests: write
23+
steps:
24+
- name: Validate PR title
25+
uses: actions/github-script@v7
26+
with:
27+
script: |
28+
const title = context.payload.pull_request.title;
29+
const validPrefixes = ['feat:', 'fix:', 'docs:', 'chore:', 'refactor:', 'test:'];
30+
const isValid = validPrefixes.some(prefix => title.startsWith(prefix));
31+
32+
if (!isValid) {
33+
const body = `👋 Thanks for opening this PR!
34+
35+
Your PR title \`${title}\` doesn't follow our conventional commit format.
36+
37+
Please update it to start with one of these prefixes:
38+
- \`feat:\` new feature or functionality
39+
- \`fix:\` bug fix
40+
- \`docs:\` documentation or README changes
41+
- \`chore:\` maintenance tasks, dependency updates, etc.
42+
- \`refactor:\` code refactoring without changing behavior
43+
- \`test:\` adding or updating tests
44+
45+
**Examples:**
46+
- \`docs: update contributing guidelines\`
47+
- \`fix: resolve crash on startup\`
48+
- \`feat: add dark mode support\`
49+
50+
See [CONTRIBUTING.md](../blob/dev/CONTRIBUTING.md#pr-titles) for more details.`;
51+
52+
await github.rest.issues.createComment({
53+
owner: context.repo.owner,
54+
repo: context.repo.repo,
55+
issue_number: context.payload.pull_request.number,
56+
body: body
57+
});
58+
59+
core.setFailed('PR title does not follow conventional commit format');
60+
} else {
61+
console.log('PR title is valid:', title);
62+
}

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,24 @@ With that said, you may want to try these methods, as they might work for you.
155155
- Avoid having verbose LLM generated PR descriptions
156156
- Before adding new functions or functionality, ensure that such behavior doesn't already exist elsewhere in the codebase.
157157

158+
### PR Titles
159+
160+
PR titles should follow conventional commit standards:
161+
162+
- `feat:` new feature or functionality
163+
- `fix:` bug fix
164+
- `docs:` documentation or README changes
165+
- `chore:` maintenance tasks, dependency updates, etc.
166+
- `refactor:` code refactoring without changing behavior
167+
- `test:` adding or updating tests
168+
169+
Examples:
170+
171+
- `docs: update contributing guidelines`
172+
- `fix: resolve crash on startup`
173+
- `feat: add dark mode support`
174+
- `chore: bump dependency versions`
175+
158176
### Style Preferences
159177

160178
These are not strictly enforced, they are just general guidelines:

0 commit comments

Comments
 (0)