Skip to content

Commit 9c1b4eb

Browse files
authored
CI: Claude review, trigger logic [skip ci] (#8923)
1 parent 07368d6 commit 9c1b4eb

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

‎.github/workflows/claude-review.yml‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
# 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.
29
name: claude-review
310

411
on:
5-
pull_request:
12+
pull_request_target:
613
types: [opened, synchronize, ready_for_review, reopened]
14+
issue_comment:
15+
types: [created]
716

817
jobs:
918
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))
1127
1228
runs-on: ubuntu-24.04
1329

@@ -17,6 +33,7 @@ jobs:
1733
id-token: write
1834

1935
steps:
36+
# checks out the base branch, not the PR head
2037
- uses: actions/checkout@v7
2138
with:
2239
fetch-depth: 1
@@ -27,7 +44,7 @@ jobs:
2744
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
2845
prompt: |
2946
REPO: ${{ github.repository }}
30-
PR NUMBER: ${{ github.event.pull_request.number }}
47+
PR NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
3148
3249
Review this pull request. Focus on correctness bugs, potential
3350
false positives/false negatives in checkers, performance problems

0 commit comments

Comments
 (0)