mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
docs: add PR title guidelines and workflow to enforce conventional commits
This commit is contained in:
62
.github/workflows/pr-title.yml
vendored
Normal file
62
.github/workflows/pr-title.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
name: PR Title Validation
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, edited, synchronize]
|
||||
|
||||
jobs:
|
||||
validate-title:
|
||||
if: |
|
||||
github.event.pull_request.user.login != 'actions-user' &&
|
||||
github.event.pull_request.user.login != 'opencode' &&
|
||||
github.event.pull_request.user.login != 'rekram1-node' &&
|
||||
github.event.pull_request.user.login != 'thdxr' &&
|
||||
github.event.pull_request.user.login != 'kommander' &&
|
||||
github.event.pull_request.user.login != 'jayair' &&
|
||||
github.event.pull_request.user.login != 'fwang' &&
|
||||
github.event.pull_request.user.login != 'adamdotdevin' &&
|
||||
github.event.pull_request.user.login != 'iamdavidhill' &&
|
||||
github.event.pull_request.user.login != 'opencode-agent[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Validate PR title
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const title = context.payload.pull_request.title;
|
||||
const validPrefixes = ['feat:', 'fix:', 'docs:', 'chore:', 'refactor:', 'test:'];
|
||||
const isValid = validPrefixes.some(prefix => title.startsWith(prefix));
|
||||
|
||||
if (!isValid) {
|
||||
const body = `👋 Thanks for opening this PR!
|
||||
|
||||
Your PR title \`${title}\` doesn't follow our conventional commit format.
|
||||
|
||||
Please update it to start with one of these prefixes:
|
||||
- \`feat:\` new feature or functionality
|
||||
- \`fix:\` bug fix
|
||||
- \`docs:\` documentation or README changes
|
||||
- \`chore:\` maintenance tasks, dependency updates, etc.
|
||||
- \`refactor:\` code refactoring without changing behavior
|
||||
- \`test:\` adding or updating tests
|
||||
|
||||
**Examples:**
|
||||
- \`docs: update contributing guidelines\`
|
||||
- \`fix: resolve crash on startup\`
|
||||
- \`feat: add dark mode support\`
|
||||
|
||||
See [CONTRIBUTING.md](../blob/dev/CONTRIBUTING.md#pr-titles) for more details.`;
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
body: body
|
||||
});
|
||||
|
||||
core.setFailed('PR title does not follow conventional commit format');
|
||||
} else {
|
||||
console.log('PR title is valid:', title);
|
||||
}
|
||||
@@ -155,6 +155,24 @@ With that said, you may want to try these methods, as they might work for you.
|
||||
- Avoid having verbose LLM generated PR descriptions
|
||||
- Before adding new functions or functionality, ensure that such behavior doesn't already exist elsewhere in the codebase.
|
||||
|
||||
### PR Titles
|
||||
|
||||
PR titles should follow conventional commit standards:
|
||||
|
||||
- `feat:` new feature or functionality
|
||||
- `fix:` bug fix
|
||||
- `docs:` documentation or README changes
|
||||
- `chore:` maintenance tasks, dependency updates, etc.
|
||||
- `refactor:` code refactoring without changing behavior
|
||||
- `test:` adding or updating tests
|
||||
|
||||
Examples:
|
||||
|
||||
- `docs: update contributing guidelines`
|
||||
- `fix: resolve crash on startup`
|
||||
- `feat: add dark mode support`
|
||||
- `chore: bump dependency versions`
|
||||
|
||||
### Style Preferences
|
||||
|
||||
These are not strictly enforced, they are just general guidelines:
|
||||
|
||||
Reference in New Issue
Block a user