-
Notifications
You must be signed in to change notification settings - Fork 0
feat(github,commit): remove terminal-ui-design, add batch ops and PR templates #20
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| --- | ||
| description: >- | ||
| Agentic workflow for PR automation: auto-label based on changed files, | ||
| auto-assign reviewers based on code ownership, and welcome first-time contributors. | ||
| --- | ||
|
|
||
| # PR Automation Workflow | ||
|
|
||
| Automatically triages pull requests with labels, reviewers, and welcome messages. | ||
|
|
||
| ## Triggers | ||
|
|
||
| - `pull_request: opened` - When a new PR is opened | ||
| - `pull_request: reopened` - When a PR is reopened | ||
|
|
||
| ## Features | ||
|
|
||
| ### Auto-Label | ||
| Labels PRs based on changed file paths: | ||
| - `area:api` - Changes in `src/api/` or `api/` | ||
| - `area:frontend` - Changes in `src/frontend/`, `components/`, or `ui/` | ||
| - `area:backend` - Changes in `src/backend/` or `server/` | ||
| - `area:docs` - Changes in `docs/` or `*.md` files | ||
| - `area:tests` - Changes in `tests/` or `test/` | ||
| - `type:breaking` - If commit contains "BREAKING CHANGE" | ||
| - `documentation` - If only documentation files changed | ||
|
|
||
| ### Auto-Assign Reviewers | ||
| Assigns reviewers based on changed files: | ||
| - Frontend changes → `frontend-team` team | ||
| - Backend changes → `backend-team` team | ||
| - API changes → `api-team` team | ||
| - Infrastructure → `devops-team` team | ||
|
|
||
| ### Welcome First-Time Contributors | ||
| For first-time contributors: | ||
| - Adds `first-time-contributor` label | ||
| - Posts welcome message with contribution guidelines | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Custom Labels | ||
| Edit the workflow file to add custom label patterns: | ||
|
|
||
| ```yaml | ||
| - name: Auto-label | ||
| run: | | ||
| # Add custom patterns here | ||
| if echo "$FILES" | grep -q "^path/to/files/"; then | ||
| gh pr edit "$PR_NUMBER" --add-label "custom-label" | ||
| fi | ||
| ``` | ||
|
|
||
| ### Custom Reviewers | ||
| Edit the reviewer mapping: | ||
|
|
||
| ```yaml | ||
| - name: Auto-assign reviewers | ||
| run: | | ||
| # Map file paths to reviewers/teams | ||
| if echo "$FILES" | grep -q "^your/path/"; then | ||
| gh pr edit "$PR_NUMBER" --add-reviewer "your-team" | ||
| fi | ||
| ``` | ||
|
|
||
| ### Custom Welcome Message | ||
| Edit the welcome comment: | ||
|
|
||
| ```yaml | ||
| - name: Welcome first-time contributors | ||
| run: | | ||
| gh pr comment "$PR_NUMBER" --body "Your custom welcome message" | ||
| ``` | ||
|
|
||
| ## Permissions | ||
|
|
||
| The workflow requires the following permissions: | ||
| - `pull-requests: write` - To add labels and comments | ||
| - `contents: read` - To read repository files | ||
|
|
||
| ## Usage | ||
|
|
||
| The workflow runs automatically on PR creation. No manual invocation needed. | ||
|
|
||
| To test changes to the workflow: | ||
| 1. Create a test branch | ||
| 2. Make a small change | ||
| 3. Open a PR | ||
| 4. Verify labels and assignments are applied | ||
|
|
||
| ## Example Output | ||
|
|
||
| For a PR changing `src/api/users.ts`: | ||
| - Labels applied: `area:api`, `area:backend` | ||
| - Reviewers assigned: `api-team` | ||
| - If first-time contributor: Welcome comment posted | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,123 @@ | ||||||||||||||||||
| name: PR Automation | ||||||||||||||||||
|
|
||||||||||||||||||
| on: | ||||||||||||||||||
| pull_request: | ||||||||||||||||||
| types: [opened, reopened] | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Workflow should react to new commits on existing PRs. Only Suggested fix- types: [opened, reopened]
+ types: [opened, reopened, synchronize]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| permissions: | ||||||||||||||||||
| pull-requests: write | ||||||||||||||||||
| contents: read | ||||||||||||||||||
|
|
||||||||||||||||||
| jobs: | ||||||||||||||||||
| pr-automation: | ||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||
| steps: | ||||||||||||||||||
| - name: Checkout | ||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Get changed files | ||||||||||||||||||
| id: changed-files | ||||||||||||||||||
| run: | | ||||||||||||||||||
| # Get list of changed files | ||||||||||||||||||
| FILES=$(gh pr diff "$PR_NUMBER" --name-only) | ||||||||||||||||||
| echo "files<<EOF" >> $GITHUB_OUTPUT | ||||||||||||||||||
| echo "$FILES" >> $GITHUB_OUTPUT | ||||||||||||||||||
| echo "EOF" >> $GITHUB_OUTPUT | ||||||||||||||||||
| env: | ||||||||||||||||||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Auto-label based on files | ||||||||||||||||||
| run: | | ||||||||||||||||||
| PR_NUMBER=${{ github.event.pull_request.number }} | ||||||||||||||||||
| FILES="${{ steps.changed-files.outputs.files }}" | ||||||||||||||||||
|
|
||||||||||||||||||
| # Area labels based on file paths | ||||||||||||||||||
| if echo "$FILES" | grep -q "^src/api/\|^api/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "area:api" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if echo "$FILES" | grep -q "^src/frontend/\|^components/\|^ui/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "area:frontend" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if echo "$FILES" | grep -q "^src/backend/\|^server/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "area:backend" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if echo "$FILES" | grep -q "^docs/\|\.md$"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "area:docs" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if echo "$FILES" | grep -q "^tests/\|^test/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "area:tests" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # Check for breaking changes in commits | ||||||||||||||||||
| COMMITS=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER/commits --jq '.[].commit.message' | grep -i "BREAKING CHANGE" || true) | ||||||||||||||||||
| if [ -n "$COMMITS" ]; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "type:breaking" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # Documentation only | ||||||||||||||||||
| if echo "$FILES" | grep -v "^docs/\|\.md$" | grep -q .; then | ||||||||||||||||||
| : | ||||||||||||||||||
| else | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "documentation" | ||||||||||||||||||
| fi | ||||||||||||||||||
| env: | ||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Auto-assign reviewers based on files | ||||||||||||||||||
| run: | | ||||||||||||||||||
| PR_NUMBER=${{ github.event.pull_request.number }} | ||||||||||||||||||
| FILES="${{ steps.changed-files.outputs.files }}" | ||||||||||||||||||
|
|
||||||||||||||||||
| # Assign reviewers based on code areas | ||||||||||||||||||
| if echo "$FILES" | grep -q "^src/frontend/\|^components/\|^ui/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-reviewer "frontend-team" || true | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if echo "$FILES" | grep -q "^src/backend/\|^server/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-reviewer "backend-team" || true | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if echo "$FILES" | grep -q "^src/api/\|^api/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-reviewer "api-team" || true | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if echo "$FILES" | grep -q "^infra/\|^deploy/\|^\.github/"; then | ||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-reviewer "devops-team" || true | ||||||||||||||||||
| fi | ||||||||||||||||||
| env: | ||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Welcome first-time contributors | ||||||||||||||||||
| run: | | ||||||||||||||||||
| PR_NUMBER=${{ github.event.pull_request.number }} | ||||||||||||||||||
| AUTHOR=${{ github.event.pull_request.user.login }} | ||||||||||||||||||
|
|
||||||||||||||||||
| # Check if this is the author's first PR | ||||||||||||||||||
| PR_COUNT=$(gh pr list --author "$AUTHOR" --state all --limit 1 --json number --jq 'length') | ||||||||||||||||||
|
|
||||||||||||||||||
| if [ "$PR_COUNT" -eq 1 ]; then | ||||||||||||||||||
|
Comment on lines
+101
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): The first-time contributor detection will evaluate to true for any author with at least one PR in this repo, not just their first. With |
||||||||||||||||||
| gh pr edit "$PR_NUMBER" --add-label "first-time-contributor" | ||||||||||||||||||
|
Comment on lines
+101
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/pr-automation.yml | sed -n '90,115p'Repository: duyet/claude-plugins Length of output: 1290 🏁 Script executed: # Verify the --limit 1 behavior and confirm the jq 'length' logic is the issue
# by checking if there are any other PR filtering mechanisms in the file
rg -n "gh pr list" .github/workflows/pr-automation.ymlRepository: duyet/claude-plugins Length of output: 169 First-time contributor detection is logically incorrect and produces false positives. At Line 101, using The fix requires checking if the author has exactly one PR (the current one) by increasing the limit to 2: Suggested fix-PR_COUNT=$(gh pr list --author "$AUTHOR" --state all --limit 1 --json number --jq 'length')
+PR_COUNT=$(gh pr list --author "$AUTHOR" --state all --limit 2 --json number --jq 'length')
-if [ "$PR_COUNT" -eq 1 ]; then
+if [ "${{ github.event.action }}" = "opened" ] && [ "$PR_COUNT" -eq 1 ]; then📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| gh pr comment "$PR_NUMBER" --body '## Welcome! 👋 | ||||||||||||||||||
|
|
||||||||||||||||||
| Thank you for your first contribution to this project! We appreciate you taking the time to improve our codebase. | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Next Steps | ||||||||||||||||||
| - A maintainer will review your PR shortly | ||||||||||||||||||
| - Please check for any review comments and address them | ||||||||||||||||||
| - Feel free to ask questions if anything is unclear | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Contribution Guidelines | ||||||||||||||||||
| - Ensure all tests pass | ||||||||||||||||||
| - Update documentation if needed | ||||||||||||||||||
| - Keep changes focused and atomic | ||||||||||||||||||
|
|
||||||||||||||||||
| Thanks again for contributing! 🎉' | ||||||||||||||||||
| fi | ||||||||||||||||||
| env: | ||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| ## Summary | ||
| Fixes {{ issue description }} | ||
|
|
||
| ## Root Cause | ||
| {{ explanation of what was causing the bug }} | ||
|
|
||
| ## Solution | ||
| {{ how the bug was fixed }} | ||
|
|
||
| ## Changes | ||
| - {{ change 1 }} | ||
| - {{ change 2 }} | ||
|
|
||
| ## Testing | ||
| {{ how the fix was tested }} | ||
|
|
||
| ## Regression Risk | ||
| {{ assessment of potential side effects }} | ||
|
|
||
| ## Related Issues | ||
| Closes #{{ issue number }} | ||
|
|
||
| --- | ||
| Generated with [Claude Code](https://claude.com/claude-code) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ## Summary | ||
| {{ brief description of what this PR does }} | ||
|
|
||
| ## Changes | ||
| - {{ key change 1 }} | ||
| - {{ key change 2 }} | ||
| - {{ key change 3 }} | ||
|
|
||
| ## Context | ||
| {{ background information, motivation, or link to issue }} | ||
|
|
||
| ## Testing | ||
| {{ how the changes were tested }} | ||
|
|
||
| ## Checklist | ||
| - [ ] Tests pass | ||
| - [ ] Documentation updated (if needed) | ||
| - [ ] No breaking changes (or documented) | ||
|
|
||
| --- | ||
| Generated with [Claude Code](https://claude.com/claude-code) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ## Summary | ||
| {{ feature description }} | ||
|
|
||
| ## Motivation | ||
| {{ why this feature is needed }} | ||
|
|
||
| ## Implementation | ||
| {{ high-level overview of implementation }} | ||
|
|
||
| ## Changes | ||
| - {{ change 1 }} | ||
| - {{ change 2 }} | ||
| - {{ change 3 }} | ||
|
|
||
| ## Breaking Changes | ||
| {{ list any breaking changes, or "None" }} | ||
|
|
||
| ## Migration Guide | ||
| {{ if breaking changes, how users should migrate }} | ||
|
|
||
| ## Testing | ||
| {{ how the feature was tested }} | ||
|
|
||
| ## Documentation | ||
| {{ link to documentation updates, or "N/A" }} | ||
|
|
||
| ## Related Issues | ||
| Closes #{{ issue number }} | ||
|
|
||
| --- | ||
| Generated with [Claude Code](https://claude.com/claude-code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example output labels are inconsistent with the documented path rules.
For a PR changing
src/api/users.ts,area:backendshould not be listed unless backend paths are also changed.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents