Skip to content

Commit 67173ca

Browse files
Allow to trigger code review on another repo
For easily testing code review, allow to run the action manually. The target repo and PR can be specified, as well as the plugin marketplace to install. Issue: ZENKO-5260
1 parent 336ef6a commit 67173ca

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ on:
3131
- comment: post as a PR comment
3232
- auto: check if allowed, otherwise post as a comment
3333
default: auto
34+
repository:
35+
type: string
36+
description: Name of the repository to review (without owner — must be in the same owner as the workflow). Defaults to the current repository.
37+
default: ${{ github.event.repository.name }}
38+
pull_request_number:
39+
type: string
40+
description: Pull request number to review. Defaults to the PR that triggered the workflow.
41+
default: ${{ github.event.pull_request.number }}
3442
ACTIONS_APP_ID:
3543
type: string
3644
description: >
@@ -68,8 +76,32 @@ jobs:
6876
id-token: write # claude-code-action needs this to authenticate with GitHub
6977

7078
steps:
79+
- name: Get token for PR repository
80+
if: inputs.repository
81+
id: pr-token
82+
uses: actions/create-github-app-token@v3
83+
with:
84+
app-id: ${{ inputs.ACTIONS_APP_ID }}
85+
private-key: ${{ secrets.ACTIONS_APP_PRIVATE_KEY }}
86+
owner: ${{ github.repository_owner }}
87+
repositories: ${{ inputs.repository }}
88+
89+
- name: Compute PR branch
90+
if: inputs.repository || inputs.pull_request_number
91+
id: pr-branch
92+
env:
93+
GH_TOKEN: ${{ steps.pr-token.outputs.token || github.token }}
94+
REPOSITORY: ${{ github.repository_owner }}/${{ inputs.repository }}
95+
PR_NUMBER: ${{ inputs.pull_request_number }}
96+
run: |
97+
branch=$(gh pr view "$PR_NUMBER" --repo "$REPOSITORY" --json headRefName --jq .headRefName)
98+
echo "ref=$branch" >> "$GITHUB_OUTPUT"
99+
71100
- uses: actions/checkout@v6
72101
with:
102+
repository: ${{ github.repository_owner }}/${{ inputs.repository }}
103+
ref: ${{ steps.pr-branch.outputs.ref || github.ref }}
104+
token: ${{ steps.pr-token.outputs.token || github.token }}
73105
fetch-depth: 1
74106

75107
- name: Identify marketplaces needing local checkout
@@ -135,7 +167,8 @@ jobs:
135167
uses: anthropics/claude-code-action@v1
136168
with:
137169
use_vertex: "true"
138-
prompt: "/review-pr REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }}"
170+
github_token: ${{ steps.pr-token.outputs.token || github.token }}
171+
prompt: "/review-pr REPO: ${{ github.repository_owner }}/${{ inputs.repository }} PR_NUMBER: ${{ inputs.pull_request_number }}"
139172
claude_args: |
140173
--allowedTools "Read" "Bash(git diff *)" "Bash(git log *)" "Bash(git show *)" "Bash(gh repo view *)" "Bash(gh pr view *)" "Bash(gh pr diff *)" "Bash(gh pr checks *)" "Bash(gh pr comment *)" "Bash(gh api *repos/*/pulls/*/comments*)" "Bash(gh api *issues/*/comments*)" "Bash(gh api *repos/*/check-runs*)"
141174
--model "${{ inputs.model }}"

0 commit comments

Comments
 (0)