Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Claude Code Review

on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to review'
required: true
type: string
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
paths-ignore:
Expand All @@ -17,18 +23,30 @@ permissions:
jobs:
claude-review:
if: |
github.actor != 'coderabbitai[bot]' &&
!contains(github.event.pull_request.title, '[skip review]') &&
!contains(github.event.pull_request.labels.*.name, 'skip-review')
github.event_name == 'workflow_dispatch' || (
github.actor != 'coderabbitai[bot]' &&
!contains(github.event.pull_request.title, '[skip review]') &&
!contains(github.event.pull_request.labels.*.name, 'skip-review')
)
Comment on lines 25 to +30
concurrency:
group: claude-review-${{ github.event.pull_request.number }}
group: claude-review-${{ github.event.pull_request.number || inputs.pr_number }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Resolve PR
id: pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }}
run: |
HEAD_REF=$(gh pr view "$PR_NUMBER" --repo "${{ github.repository }}" --json headRefName -q .headRefName)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check out the PR's exact head ref

For a manual rerun of a PR whose head branch lives in a fork, gh pr view --json headRefName resolves only the branch name, while the following actions/checkout step still defaults to checking out ${{ github.repository }}. In that case the workflow either fails to find the fork branch or reviews a same-named branch in the base repo instead of the requested PR. Resolve an exact PR ref/SHA such as headRefOid or refs/pull/<number>/head, or also pass the head repository to checkout.

Useful? React with πŸ‘Β / πŸ‘Ž.

echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
echo "head_ref=$HEAD_REF" >> "$GITHUB_OUTPUT"

- name: Checkout PR head
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
Comment on lines +42 to 48
ref: ${{ github.event.pull_request.head.ref }}
ref: ${{ steps.pr.outputs.head_ref }}
fetch-depth: 20

- name: Run Claude Code Review (agentic)
Expand All @@ -42,7 +60,7 @@ jobs:
plugins: 'code-review@claude-code-plugins'
claude_args: '--model claude-opus-4-7 --max-turns 25'
prompt: |
/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}
/code-review:code-review ${{ github.repository }}/pull/${{ steps.pr.outputs.number }}

Operating mode: **agentic**. You have write access to this PR branch.

Expand Down
Loading