|  | 
| 30 | 30 |         with: | 
| 31 | 31 |           fetch-depth: 1 | 
| 32 | 32 | 
 | 
|  | 33 | +      - name: Checkout PR branch (if comment is on a PR) | 
|  | 34 | +        if: github.event.issue.pull_request || github.event.pull_request | 
|  | 35 | +        env: | 
|  | 36 | +          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | 
|  | 37 | +        run: | | 
|  | 38 | +          if [ -n "${{ github.event.issue.number }}" ]; then | 
|  | 39 | +            PR_NUMBER="${{ github.event.issue.number }}" | 
|  | 40 | +          elif [ -n "${{ github.event.pull_request.number }}" ]; then | 
|  | 41 | +            PR_NUMBER="${{ github.event.pull_request.number }}" | 
|  | 42 | +          fi | 
|  | 43 | +
 | 
|  | 44 | +          if [ -n "$PR_NUMBER" ]; then | 
|  | 45 | +            echo "Detected comment on PR #$PR_NUMBER" | 
|  | 46 | +
 | 
|  | 47 | +            # Check if it's a forked PR | 
|  | 48 | +            PR_INFO=$(gh pr view $PR_NUMBER --json isCrossRepository,headRepositoryOwner 2>/dev/null || echo '{}') | 
|  | 49 | +            IS_FORK=$(echo "$PR_INFO" | jq -r '.isCrossRepository // false') | 
|  | 50 | +
 | 
|  | 51 | +            if [ "$IS_FORK" = "true" ]; then | 
|  | 52 | +              echo "⚠️  Forked PR detected - running in secure mode" | 
|  | 53 | +              FORK_OWNER=$(echo "$PR_INFO" | jq -r '.headRepositoryOwner.login') | 
|  | 54 | +              echo "PR from: $FORK_OWNER" | 
|  | 55 | +            fi | 
|  | 56 | +
 | 
|  | 57 | +            echo "Checking out PR #$PR_NUMBER" | 
|  | 58 | +            gh pr checkout $PR_NUMBER | 
|  | 59 | +            echo "✅ PR branch checked out successfully" | 
|  | 60 | +          fi | 
|  | 61 | +
 | 
| 33 | 62 |       - name: Run Claude Code | 
| 34 | 63 |         id: claude | 
| 35 | 64 |         uses: anthropics/claude-code-action@v1 | 
|  | 
| 39 | 68 |           # This is an optional setting that allows Claude to read CI results on PRs | 
| 40 | 69 |           additional_permissions: | | 
| 41 | 70 |             actions: read | 
| 42 |  | -
 | 
| 43 |  | -          # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. | 
| 44 |  | -          # prompt: 'Update the pull request description to include a summary of changes.' | 
| 45 |  | - | 
| 46 |  | -          # Optional: Add claude_args to customize behavior and configuration | 
| 47 |  | -          # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md | 
| 48 |  | -          # or https://docs.claude.com/en/docs/claude-code/cli-reference for available options | 
| 49 |  | -          # claude_args: '--allowed-tools Bash(gh pr:*)' | 
|  | 
0 commit comments