|
| 1 | +name: Claude AI Review with inline comments |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + pull_request_review_comment: |
| 7 | + types: [created] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pull-requests: write |
| 12 | + issues: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + claude-ai-review: |
| 16 | + if: | |
| 17 | + ( |
| 18 | + github.event_name == 'issue_comment' && |
| 19 | + github.event.issue.pull_request && |
| 20 | + github.event.issue.state == 'open' && |
| 21 | + contains(github.event.comment.body, '@claude') && |
| 22 | + (github.event.comment.author_association == 'MEMBER' || |
| 23 | + github.event.comment.author_association == 'OWNER' || |
| 24 | + github.event.comment.author_association == 'COLLABORATOR') |
| 25 | + ) || ( |
| 26 | + github.event_name == 'pull_request_review_comment' && |
| 27 | + contains(github.event.comment.body, '@claude') && |
| 28 | + (github.event.comment.author_association == 'MEMBER' || |
| 29 | + github.event.comment.author_association == 'OWNER' || |
| 30 | + github.event.comment.author_association == 'COLLABORATOR') |
| 31 | + ) |
| 32 | + concurrency: |
| 33 | + group: claude-ai-review-${{ github.event.issue.number || github.event.pull_request.number }} |
| 34 | + cancel-in-progress: false |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: Resolve PR number |
| 38 | + id: pr |
| 39 | + run: | |
| 40 | + NUM="${{ github.event.issue.number || github.event.pull_request.number }}" |
| 41 | + echo "number=${NUM}" >> "$GITHUB_OUTPUT" |
| 42 | +
|
| 43 | + - name: Check out PR head (shallow) |
| 44 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 45 | + with: |
| 46 | + ref: refs/pull/${{ steps.pr.outputs.number }}/head |
| 47 | + fetch-depth: 1 |
| 48 | + |
| 49 | + - name: Strip fork-supplied reviewer/agent config |
| 50 | + # ai-reviewer fetches its config (.ai/review-rules.md, .ai/review-tools.json, |
| 51 | + # .ai/context-script) from the base repo's default branch via the GitHub |
| 52 | + # Contents API, so wiping the fork's local copies does not affect rule |
| 53 | + # loading. The wipe matters because the action also exposes read-only |
| 54 | + # browse tools (read_file/list_dir/grep) rooted at the PR-head checkout — |
| 55 | + # without this step a fork could ship its own .ai/review-tools.json or |
| 56 | + # .ai/context-script and surface them to the LLM. .claude/ + CLAUDE.md |
| 57 | + # are wiped for parity with the hardening in claude_review.yml. |
| 58 | + run: rm -rf .ai/ .claude/ CLAUDE.md |
| 59 | + |
| 60 | + - uses: tarekziade/ai-reviewer@main |
| 61 | + with: |
| 62 | + llm_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 63 | + llm_api_base: https://api.anthropic.com |
| 64 | + llm_model: claude-opus-4-6 |
| 65 | + llm_stream: 'true' |
| 66 | + mention_trigger: '@goku' |
0 commit comments