|
1 | 1 | # Automated code review of pull requests using Claude |
| 2 | +# |
| 3 | +# - PRs opened by members/owners/collaborators are reviewed automatically. |
| 4 | +# - For other PRs a member/owner/collaborator can request a review by writing |
| 5 | +# a PR comment containing "@claude review". |
| 6 | +# |
| 7 | +# pull_request_target and issue_comment run the workflow file from the base |
| 8 | +# branch with access to secrets. The PR code is never checked out or executed. |
2 | 9 | name: claude-review |
3 | 10 |
|
4 | 11 | on: |
5 | | - pull_request: |
| 12 | + pull_request_target: |
6 | 13 | types: [opened, synchronize, ready_for_review, reopened] |
| 14 | + issue_comment: |
| 15 | + types: [created] |
7 | 16 |
|
8 | 17 | jobs: |
9 | 18 | review: |
10 | | - if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository |
| 19 | + if: | |
| 20 | + (github.event_name == 'pull_request_target' && |
| 21 | + github.event.pull_request.draft == false && |
| 22 | + contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)) || |
| 23 | + (github.event_name == 'issue_comment' && |
| 24 | + github.event.issue.pull_request && |
| 25 | + contains(github.event.comment.body, '@claude review') && |
| 26 | + contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) |
11 | 27 |
|
12 | 28 | runs-on: ubuntu-24.04 |
13 | 29 |
|
|
17 | 33 | id-token: write |
18 | 34 |
|
19 | 35 | steps: |
| 36 | + # checks out the base branch, not the PR head |
20 | 37 | - uses: actions/checkout@v7 |
21 | 38 | with: |
22 | 39 | fetch-depth: 1 |
|
27 | 44 | anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
28 | 45 | prompt: | |
29 | 46 | REPO: ${{ github.repository }} |
30 | | - PR NUMBER: ${{ github.event.pull_request.number }} |
| 47 | + PR NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} |
31 | 48 |
|
32 | 49 | Review this pull request. Focus on correctness bugs, potential |
33 | 50 | false positives/false negatives in checkers, performance problems |
|
0 commit comments