-
Notifications
You must be signed in to change notification settings - Fork 97
ci: fix Claude Code Review workflow to post PR comments #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
2348a86
ci: fix Claude Code Review workflow to post PR comments
tianjianjiang 76b6d1e
ci: skip fork PRs gracefully and allow workflow self-testing
tianjianjiang 44bbfda
ci: restore paths-ignore to prevent OIDC validation errors
tianjianjiang cf370da
ci: switch to MCP GitHub tools for reliable PR review posting
tianjianjiang d7a697f
ci: add mcp__github__get_pull_request to claude.yml for consistency
tianjianjiang 3ee085e
ci: refactor to reusable workflow and add mcp__github__get_me
tianjianjiang 02e01cd
style: use multiline yaml per Coplit review
tianjianjiang b67b868
ci: fix action syntax per Copilot review
tianjianjiang 119bd35
ci: replicate permissions per Copilot review
tianjianjiang 2ddad7e
ci: replicate permissions per Copilot review
tianjianjiang d330005
ci: add mcp__github__list_pull_requests to prevent permission denials
tianjianjiang 632b4d1
ci: fix permissions for Claude workflows to enable PR comment posting
tianjianjiang 6ed24e4
ci: update actions/checkout to v5 in Claude reusable workflow
tianjianjiang ef58b77
ci: standardize Claude workflow permissions and fix OIDC validation
tianjianjiang ec00bd9
ci: add max-turns parameter to prevent Claude turn exhaustion
tianjianjiang bd74079
ci: add concurrency control to Claude workflows
tianjianjiang e89db76
ci: add timeout and error handling to Claude review step
tianjianjiang 0a3e6e5
ci: add enhanced logging for Claude review results
tianjianjiang bdf7f15
ci: add workflow status reporting for Claude review failures
tianjianjiang 2eb1eaa
c: apply suggestion from @Copilot
tianjianjiang 9e25833
ci: fix YAML comment indentation in claude-code-review workflow
tianjianjiang 204bd77
ci: fix event condition in reusable workflow failure reporting
tianjianjiang 2b61375
ci: improve claude_args configuration readability in reusable workflow
tianjianjiang 404049b
ci: improve error message readability in Claude failure reporting
tianjianjiang 101f14b
ci: improve workflow conditions to reduce manual approval requirements
tianjianjiang 779c3ab
ci: add Copilot bot exclusions to prevent manual approval triggers
tianjianjiang 5a5cb03
ci: fix Copilot bot names to use correct GitHub identifiers
tianjianjiang a51d166
ci: remove deprecated claude_args_override parameter
tianjianjiang d001d47
ci: apply suggestion from @Copilot
tianjianjiang d8f97f3
ci: fix Claude workflow to only run on PR-related events
tianjianjiang 395a7ff
ci: fix Copilot bot name to use correct GitHub Apps identifier
tianjianjiang 9b36841
ci: remove redundant permissions from reusable workflow
tianjianjiang f66bc92
ci: enhance workflow conditions and add repository settings guidance
tianjianjiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| name: Claude PR Review (Reusable) | ||
|
|
||
| # Reusable workflow for Claude Code PR reviews | ||
| # Used by both claude.yml and claude-code-review.yml to maintain consistency | ||
| # and eliminate duplication of MCP tool configuration. | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| prompt: | ||
| description: 'The prompt to send to Claude for PR review' | ||
| required: true | ||
| type: string | ||
| claude_args: | ||
| description: 'Claude arguments for the review' | ||
| required: false | ||
| type: string | ||
| default: '--max-turns 10 --allowedTools mcp__github__get_me,mcp__github__get_pull_request,mcp__github__list_pull_requests,mcp__github__create_pending_pull_request_review,mcp__github__get_pull_request_diff,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review' | ||
|
tianjianjiang marked this conversation as resolved.
|
||
| secrets: | ||
| CLAUDE_CODE_OAUTH_TOKEN: | ||
| description: 'OAuth token for Claude Code authentication' | ||
| required: true | ||
|
|
||
| jobs: | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| # Note: Permissions are inherited from calling workflows (claude.yml, claude-code-review.yml) | ||
| # Caller permissions take precedence over reusable workflow permissions | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
tianjianjiang marked this conversation as resolved.
tianjianjiang marked this conversation as resolved.
tianjianjiang marked this conversation as resolved.
|
||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code Review | ||
| id: claude-review | ||
| timeout-minutes: 15 | ||
| continue-on-error: true | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| prompt: ${{ inputs.prompt }} | ||
|
|
||
| # Standard configuration for GitHub PR reviews | ||
| # This is the single source of truth for Claude arguments across all workflows | ||
| # | ||
| # Parameters: | ||
| # - --max-turns 10: Increase turn limit to prevent exhaustion during complex reviews | ||
| # | ||
| # Tools included: | ||
| # - mcp__github__get_me: Get authenticated user context (prevents permission denials) | ||
| # - mcp__github__get_pull_request: Get PR metadata, title, description (context understanding) | ||
| # - mcp__github__list_pull_requests: List/search PRs in the repository (context discovery) | ||
| # - mcp__github__create_pending_pull_request_review: Start a pending review | ||
| # - mcp__github__get_pull_request_diff: Get code changes and line numbers for inline comments | ||
| # - mcp__github__add_comment_to_pending_review: Add inline review comments | ||
| # - mcp__github__submit_pending_pull_request_review: Publish the review | ||
| claude_args: ${{ inputs.claude_args }} | ||
|
|
||
| - name: Log Claude Review Results | ||
| if: always() | ||
| run: | | ||
| echo "Claude review completed with status: ${{ steps.claude-review.outcome }}" | ||
| echo "Claude review conclusion: ${{ steps.claude-review.conclusion }}" | ||
| if [ "${{ steps.claude-review.outcome }}" = "failure" ]; then | ||
| echo "Claude review failed - check logs above for details" | ||
| elif [ "${{ steps.claude-review.outcome }}" = "success" ]; then | ||
| echo "Claude review completed successfully" | ||
| fi | ||
|
|
||
| - name: Report Claude Review Failure | ||
| if: steps.claude-review.outcome == 'failure' | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| FAILURE_MESSAGE: | | ||
| **Claude Code Review Failed** | ||
|
|
||
| The automated Claude review encountered an error and could not complete. You can: | ||
|
|
||
| - Check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details | ||
| - Trigger a manual review by commenting `@claude` on this PR | ||
| - The review will be retried automatically on the next push | ||
|
|
||
| This does not affect the PR approval process. | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: process.env.FAILURE_MESSAGE | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.