|
| 1 | +name: Claude Code |
| 2 | + |
| 3 | +on: |
| 4 | + # Auto-review PRs to master |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize, ready_for_review, reopened] |
| 7 | + branches: |
| 8 | + - master |
| 9 | + |
| 10 | + # @claude mentions in PR comments |
| 11 | + issue_comment: |
| 12 | + types: [created] |
| 13 | + pull_request_review_comment: |
| 14 | + types: [created] |
| 15 | + pull_request_review: |
| 16 | + types: [submitted] |
| 17 | + |
| 18 | +jobs: |
| 19 | + # Auto-review PRs targeting master |
| 20 | + auto-review: |
| 21 | + if: github.event_name == 'pull_request' && !github.event.pull_request.draft |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: read |
| 25 | + pull-requests: write |
| 26 | + id-token: write |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v6 |
| 29 | + with: |
| 30 | + fetch-depth: 1 |
| 31 | + |
| 32 | + - uses: anthropics/claude-code-action@v1 |
| 33 | + with: |
| 34 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 35 | + track_progress: true |
| 36 | + use_sticky_comment: true |
| 37 | + prompt: | |
| 38 | + REPO: ${{ github.repository }} |
| 39 | + PR NUMBER: ${{ github.event.pull_request.number }} |
| 40 | +
|
| 41 | + Perform a comprehensive code review focusing on: |
| 42 | + - Code quality and best practices |
| 43 | + - Potential bugs or security issues |
| 44 | + - Performance considerations |
| 45 | + - Test coverage |
| 46 | +
|
| 47 | + Use inline comments for specific issues. |
| 48 | + Use top-level comments for general observations. |
| 49 | +
|
| 50 | + claude_args: | |
| 51 | + --allowedTools "Read,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
| 52 | + --max-turns 15 |
| 53 | +
|
| 54 | + # Respond to @claude mentions (members only, PRs only) |
| 55 | + mention-response: |
| 56 | + if: | |
| 57 | + ( |
| 58 | + github.event_name == 'issue_comment' && |
| 59 | + github.event.issue.pull_request && |
| 60 | + contains(github.event.comment.body, '@claude') && |
| 61 | + ( |
| 62 | + github.event.comment.author_association == 'MEMBER' || |
| 63 | + github.event.comment.author_association == 'COLLABORATOR' |
| 64 | + ) |
| 65 | + ) || |
| 66 | + ( |
| 67 | + github.event_name == 'pull_request_review_comment' && |
| 68 | + contains(github.event.comment.body, '@claude') && |
| 69 | + ( |
| 70 | + github.event.comment.author_association == 'MEMBER' || |
| 71 | + github.event.comment.author_association == 'COLLABORATOR' |
| 72 | + ) |
| 73 | + ) || |
| 74 | + ( |
| 75 | + github.event_name == 'pull_request_review' && |
| 76 | + contains(github.event.review.body, '@claude') && |
| 77 | + ( |
| 78 | + github.event.review.author_association == 'MEMBER' || |
| 79 | + github.event.review.author_association == 'COLLABORATOR' |
| 80 | + ) |
| 81 | + ) |
| 82 | + runs-on: ubuntu-latest |
| 83 | + permissions: |
| 84 | + contents: read |
| 85 | + pull-requests: write |
| 86 | + id-token: write |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v6 |
| 89 | + with: |
| 90 | + fetch-depth: 1 |
| 91 | + |
| 92 | + - uses: anthropics/claude-code-action@v1 |
| 93 | + with: |
| 94 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 95 | + claude_args: | |
| 96 | + --allowedTools "Read,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
| 97 | + --max-turns 10 |
0 commit comments