Skip to content

Commit a88181c

Browse files
committed
Restrict Claude workflow to same-repo PRs only
- Add condition: only run when PR head repo equals base repo - This avoids permission errors on fork PRs - Update prompt for same-repo PR context - Claude can now successfully review and comment on PRs in your fork - Fork PRs will be skipped entirely to avoid permission issues
1 parent dd1b6b5 commit a88181c

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ on:
1313

1414
permissions:
1515
contents: read
16-
pull-requests: read
17-
issues: read
16+
pull-requests: write
17+
issues: write
1818

1919
jobs:
2020
claude-review:
21-
# Run for all PRs including forks - use PAT for fork PR commenting
21+
# Run only on same-repo PRs to avoid permission issues
2222
runs-on: ubuntu-latest
23+
if: github.event.pull_request.head.repo.full_name == github.repository
2324

2425
steps:
2526
- name: Debug PR info
@@ -47,7 +48,6 @@ jobs:
4748
REPO: ${{ github.event.pull_request.head.repo.full_name }}
4849
PR NUMBER: ${{ github.event.pull_request.number }}
4950
BASE REPO: ${{ github.repository }}
50-
HAS_PAT: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
5151
5252
Please review this pull request and provide feedback on:
5353
- Code quality and best practices
@@ -58,10 +58,8 @@ jobs:
5858
5959
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
6060
61-
IMPORTANT: Commenting permissions:
62-
- If this is a same-repo PR (HAS_PAT is true): Use \`gh pr comment ${{ github.event.pull_request.number }}\`
63-
- If this is a fork PR (HAS_PAT is false): Cannot comment on PR - just review the code without commenting
64-
- Only comment if you have write permissions to the repository
61+
IMPORTANT: This is a same-repo PR, so you can comment using:
62+
\`gh pr comment ${{ github.event.pull_request.number }}\`
6563
6664
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
6765
# or https://code.claude.com/docs/en/cli-reference for available options

0 commit comments

Comments
 (0)