Repository navigation
ci(pr-automation): stale prs and issues, pr heading and body checker, labels #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
222af93
ci(stale.yml): Configure stale workflow with new settings
Ryan-Millard fcee7be
style(stale-workflow): format properly
Ryan-Millard 099639d
deps(stale-workflow): bump to newer v10
Ryan-Millard 18d156d
ci(stale.yml): fix label inputs
Ryan-Millard ae46cff
docs(PR-template): update PR template
Ryan-Millard df3390a
ci: add PR auto-label workflow and labeler config
Ryan-Millard a74a22b
ci: PR heading and body checker
Ryan-Millard dd1f722
fix: workflow does not contain permissions
Ryan-Millard ef10fb1
style(workflows): format new workflow files
Ryan-Millard d793964
ci(deps): bump labeler to v6
Ryan-Millard af21882
ci(pr-check): fix permissions
Ryan-Millard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| c/cpp: | ||
| - "**/*.c" | ||
| - "**/*.cpp" | ||
| - "**/*.h" | ||
| - "**/*.hpp" | ||
|
|
||
| docs: | ||
| - "**/*.md" | ||
|
|
||
| ci: | ||
| - ".github/**" | ||
|
|
||
| js/ts: | ||
| - "**/*.js" | ||
| - "**/*.jsx" | ||
| - "**/*.ts" | ||
| - "**/*.tsx" | ||
| - "vite.config.*" # Vite config files | ||
| - "vite.*.js" # optional extra patterns | ||
| - "package.json" # package manifest changes | ||
| - "package-lock.json" | ||
| - "yarn.lock" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # This workflow will triage pull requests and apply a label based on the | ||
| # paths that are modified in the pull request. | ||
| # | ||
| # To use this workflow, you will need to set up a .github/labeler.yml | ||
| # file with configuration. For more information, see: | ||
| # https://github.com/actions/labeler | ||
|
|
||
| name: Labeler | ||
| on: [pull_request_target] | ||
|
|
||
| jobs: | ||
| label: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - uses: actions/labeler@v4 | ||
| with: | ||
| repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| name: PR Validation | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, edited, reopened, synchronize] | ||
|
|
||
| jobs: | ||
| title-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check PR title | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const pr = context.payload.pull_request; | ||
| const title = pr.title; | ||
|
|
||
| const isWip = title.startsWith("WIP:"); | ||
| const isDraft = pr.draft; | ||
|
|
||
| const conventionalRegex = | ||
| /^(build|ci|chore|docs|feat|fix|perf|refactor|revert|style|test)(\([^)]+\))?(!)?: .+/; | ||
|
|
||
| if (isDraft || isWip) { | ||
| core.info("Draft or WIP PR detected — skipping title enforcement."); | ||
| return; | ||
| } | ||
|
|
||
| if (!conventionalRegex.test(title)) { | ||
| core.setFailed( | ||
| `Invalid PR title.\n\n` + | ||
| `Expected:\n` + | ||
| `type(scope)!: description\n\n` + | ||
| `Allowed types:\n` + | ||
| `build, ci, chore, docs, feat, fix, perf, refactor, revert, style, test\n\n` + | ||
| `Examples:\n` + | ||
| `- feat: new feature\n` + | ||
| `- fix(scope): bug in scope\n` + | ||
| `- feat!: breaking change\n` + | ||
| `- chore(deps): update dependencies\n\n` + | ||
| `If this is WIP, prefix the title with "WIP:" or convert the PR to Draft.` | ||
| ); | ||
| } | ||
|
|
||
| body-check: | ||
|
|
||
| needs: title-check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Validate PR body | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const pr = context.payload.pull_request; | ||
| const body = pr.body || ""; | ||
| const title = pr.title || ""; | ||
|
|
||
| const isDraft = pr.draft; | ||
| const isWip = title.startsWith("WIP:"); | ||
|
|
||
| if (isDraft || isWip) { | ||
| core.info("Draft or WIP PR — skipping body enforcement."); | ||
| return; | ||
| } | ||
|
|
||
| const requiredSections = [ | ||
| "## What was changed & why", | ||
| "## Changes", | ||
| "## Testing & Verification" | ||
| ]; | ||
|
|
||
| const missingSections = requiredSections.filter( | ||
| section => !body.includes(section) | ||
| ); | ||
|
|
||
| if (missingSections.length > 0) { | ||
| core.setFailed( | ||
| `PR body is missing the following required sections:\n` + | ||
| missingSections.join("\n") + | ||
| `\n\nPlease add these sections to your PR body.` | ||
| ); | ||
| } | ||
|
|
||
| // Check for multiple issue references like "fixes #2" or "fixes: #2" | ||
| const issueReferences = [...body.matchAll(/(fixes|closes|resolves)\s*:?\s*#\d+/gi)]; | ||
|
|
||
| const hasNone = /\bnone\b/i.test(body); | ||
|
|
||
| // Convert matchAll result to boolean | ||
| const hasIssueKeyword = issueReferences.length > 0; | ||
|
|
||
| // Fail only if neither issue references nor "none" exists | ||
| if (!hasIssueKeyword && !hasNone) { | ||
| core.setFailed( | ||
| `PR must reference an issue or explicitly state "none".\n\n` + | ||
| `Use one or more of the following keywords:\n` + | ||
| `- Fixes #<issue-number>\n` + | ||
| `- Closes #<issue-number>\n` + | ||
| `- Resolves #<issue-number>\n\n` + | ||
| `You can list multiple issues:\n` + | ||
| `fixes #2\nfixes: #3\n\n` + | ||
| `If no issue applies, write "none" in the PR body.` | ||
| ); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. | ||
| # | ||
| # For more information, see: | ||
| # https://github.com/actions/stale | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| name: Mark stale issues and pull requests | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 2 * * *" # every day at 02:00 UTC | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| stale: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - uses: actions/stale@v10 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| stale-issue-message: "This issue has been inactive for 60 days. Please comment if it is still relevant or it will be closed in 14 days." | ||
| stale-pr-message: "This pull request has been inactive for 60 days. Please update it or it will be closed in 14 days." | ||
| stale-issue-label: "no-issue-activity" | ||
| stale-pr-label: "no-pr-activity" | ||
| days-before-stale: 60 | ||
| days-before-close: 14 | ||
| exempt-issue-labels: "pinned,important" | ||
| exempt-pr-labels: "pinned,important" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.