|
| 1 | +name: "Claude Code" |
| 2 | +# Note: only users with write permissions can invoke Claude jobs |
| 3 | + |
| 4 | +"on": |
| 5 | + issue_comment: |
| 6 | + types: ["created"] |
| 7 | + pull_request_review_comment: |
| 8 | + types: ["created"] |
| 9 | + issues: |
| 10 | + types: ["labeled"] |
| 11 | + pull_request_review: |
| 12 | + types: ["submitted"] |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + issue_number: |
| 16 | + description: "Issue number to process" |
| 17 | + required: true |
| 18 | + type: "number" |
| 19 | + |
| 20 | +jobs: |
| 21 | + # Disable general claude invocations |
| 22 | + # claude: |
| 23 | + # if: | |
| 24 | + # (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || |
| 25 | + # (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || |
| 26 | + # (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || |
| 27 | + # (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) |
| 28 | + # runs-on: ubuntu-latest |
| 29 | + # permissions: |
| 30 | + # contents: read |
| 31 | + # pull-requests: read |
| 32 | + # issues: read |
| 33 | + # id-token: write |
| 34 | + # actions: read # Required for Claude to read CI results on PRs |
| 35 | + # steps: |
| 36 | + # - name: Checkout repository |
| 37 | + # uses: actions/checkout@v4 |
| 38 | + # with: |
| 39 | + # fetch-depth: 1 |
| 40 | + # |
| 41 | + # - name: Run Claude Code |
| 42 | + # id: claude |
| 43 | + # uses: anthropics/claude-code-action@v1 |
| 44 | + # with: |
| 45 | + # anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 46 | + # |
| 47 | + # # This is an optional setting that allows Claude to read CI results on PRs |
| 48 | + # additional_permissions: | |
| 49 | + # actions: read |
| 50 | + # |
| 51 | + # # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. |
| 52 | + # # prompt: 'Update the pull request description to include a summary of changes.' |
| 53 | + # |
| 54 | + # # Optional: Add claude_args to customize behavior and configuration |
| 55 | + # # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md |
| 56 | + # # or https://code.claude.com/docs/en/cli-reference for available options |
| 57 | + # # claude_args: '--allowed-tools Bash(gh pr:*)' |
| 58 | + |
| 59 | + suggestion: |
| 60 | + name: "Suggestion Handler" |
| 61 | + if: | |
| 62 | + (github.event_name == 'issues' && |
| 63 | + github.event.action == 'labeled' && |
| 64 | + contains(github.event.issue.labels.*.name, 'suggestion/accepted')) || |
| 65 | + github.event_name == 'workflow_dispatch' |
| 66 | + runs-on: "ubuntu-latest" |
| 67 | + permissions: |
| 68 | + contents: "write" |
| 69 | + pull-requests: "read" |
| 70 | + issues: "write" |
| 71 | + id-token: "write" |
| 72 | + steps: |
| 73 | + - name: "Checkout repository" |
| 74 | + uses: "actions/checkout@v4" |
| 75 | + with: |
| 76 | + fetch-depth: 0 |
| 77 | + |
| 78 | + - name: "Validate issue label for manual trigger" |
| 79 | + if: "github.event_name == 'workflow_dispatch'" |
| 80 | + env: |
| 81 | + GH_TOKEN: "${{ github.token }}" |
| 82 | + ISSUE_NUMBER: "${{ inputs.issue_number }}" |
| 83 | + run: | |
| 84 | + labels=$(gh issue view $ISSUE_NUMBER --json labels --jq '.labels[].name' || echo "") |
| 85 | + if ! echo "$labels" | grep -q "suggestion/accepted"; then |
| 86 | + echo "Error: Issue #$ISSUE_NUMBER does not have the 'suggestion/accepted' label" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | + echo "Issue #$ISSUE_NUMBER has the required 'suggestion/accepted' label" |
| 90 | +
|
| 91 | + # Runs claude code implement the suggestion. |
| 92 | + # Configured to give 50 turns to claude based on observations. This can be increased if we observe sessions failing to complete |
| 93 | + - name: "Run Claude Code for Suggestion" |
| 94 | + id: "claude-suggestion" |
| 95 | + uses: "anthropics/claude-code-action@v1" |
| 96 | + env: |
| 97 | + ISSUE_NUMBER: "${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }}" |
| 98 | + with: |
| 99 | + anthropic_api_key: "${{ secrets.ANTHROPIC_API_KEY }}" |
| 100 | + # Enabling this may expose secrets. Do not set to true on public repos |
| 101 | + # https://github.com/anthropics/claude-code-action/blob/main/docs/security.md#%EF%B8%8F-full-output-security-warning |
| 102 | + show_full_output: false |
| 103 | + prompt: | |
| 104 | + Read the repository documentation structure and the issue description for issue #${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }}. |
| 105 | +
|
| 106 | + The issue has been labeled as "suggestion/accepted" and contains a documentation request or improvement. |
| 107 | +
|
| 108 | + Your task: |
| 109 | + 1. Read and understand the current documentation structure in this repository |
| 110 | + 2. Review the issue description and any comments to understand what documentation changes are needed |
| 111 | + 3. Create a new branch using the format: suggestion/issue-${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }}-<short-description> |
| 112 | + Example: suggestion/issue-1-starter-program-docs |
| 113 | + Use: git checkout -b <branch-name> |
| 114 | + 4. Implement the requested documentation changes by editing existing pages or creating new pages as appropriate |
| 115 | + 5. Ensure all changes follow the existing documentation style, formatting, and structure |
| 116 | + 6. Commit your changes with messages that include "Fixes #${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }}" so the issue will automatically close when the PR is merged. |
| 117 | + 7. Push your branch to origin using: git push -u origin <branch-name> |
| 118 | + 8. Post a comment to issue #${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }} with: |
| 119 | + - Summary of changes made |
| 120 | + - Link to create a PR using: https://github.com/${{ github.repository }}/compare/<branch-name>?expand=1 |
| 121 | + Use the gh CLI: gh issue comment ${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }} --body "<your comment>" |
| 122 | +
|
| 123 | + Focus only on documentation changes. Make app changes necessary to support the documentation such as adding visual components, icons, and structure. |
| 124 | + Otherwise, do not modify application code, configuration files, or CI/CD workflows. |
| 125 | + claude_args: | |
| 126 | + --allowedTools "Read,Write,Edit,Bash(git:*),Bash(gh:*),WebFetch(domain:authzed.com)" |
| 127 | + --max-turns 50 |
0 commit comments