From 91d2ef3fcf12a6117e16fccee1f597bff7f3c6ef Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 15:16:06 +0000 Subject: [PATCH] Add optional auto-review parameter - Add auto-review input parameter (defaults to true for backward compatibility) - Skip code review when auto-review is set to false - Update README with usage examples for disabling auto-review - Support conditional reviews based on labels or other criteria --- README.md | 27 +++++++++++++++++++++++++++ action.js | 9 +++++++++ action.yml | 4 ++++ dist/index.js | 9 +++++++++ 4 files changed, 49 insertions(+) diff --git a/README.md b/README.md index a025778..4d88760 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,32 @@ For existing pull requests, you can manually trigger the review: 3. Fill in the branch and pull request number 4. Click "Run Workflow" +### Disabling Auto-Review + +You can disable automatic reviews and only use manual triggers by setting `auto-review: false`: + +```yaml +- name: Run Claude Review + uses: pacnpal/claude-code-review@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + anthropic-key: ${{ secrets.ANTHROPIC_API_KEY }} + pr-number: ${{ github.event.pull_request.number || inputs.pr_number }} + auto-review: false # Disables automatic reviews +``` + +You can also make it conditional based on labels or other criteria: + +```yaml +- name: Run Claude Review + uses: pacnpal/claude-code-review@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + anthropic-key: ${{ secrets.ANTHROPIC_API_KEY }} + pr-number: ${{ github.event.pull_request.number || inputs.pr_number }} + auto-review: ${{ contains(github.event.pull_request.labels.*.name, 'needs-review') }} +``` + ## Setup ### Prerequisites @@ -119,6 +145,7 @@ For existing pull requests, you can manually trigger the review: | `github-token` | GitHub token for API access | Yes | N/A | | `anthropic-key` | Anthropic API key for Claude | Yes | N/A | | `pr-number` | Pull request number to review | Yes | N/A | +| `auto-review` | Enable automatic code reviews (set to `false` to skip) | No | `true` | ## Outputs diff --git a/action.js b/action.js index 923973a..a85071d 100644 --- a/action.js +++ b/action.js @@ -424,6 +424,15 @@ async function run() { const token = core.getInput('github-token', { required: true }); const anthropicKey = core.getInput('anthropic-key', { required: true }); let prNumber = core.getInput('pr-number'); + const autoReview = core.getInput('auto-review', { required: false }) || 'true'; + + // Check if auto-review is disabled + if (autoReview.toLowerCase() === 'false') { + core.info('⏭️ Auto-review is disabled, skipping code review'); + core.setOutput('diff_size', '0'); + core.setOutput('review', 'Auto-review disabled'); + return; + } // Get PR number from event if not provided const context = github.context; diff --git a/action.yml b/action.yml index 7690e02..90b27a5 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,10 @@ inputs: pr-number: description: 'Pull request number' required: true + auto-review: + description: 'Enable automatic code reviews (set to false to skip review)' + required: false + default: 'true' outputs: diff_size: description: 'Size of the relevant code changes' diff --git a/dist/index.js b/dist/index.js index 7b2e64e..829da6c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32260,6 +32260,15 @@ async function run() { const token = core.getInput('github-token', { required: true }); const anthropicKey = core.getInput('anthropic-key', { required: true }); let prNumber = core.getInput('pr-number'); + const autoReview = core.getInput('auto-review', { required: false }) || 'true'; + + // Check if auto-review is disabled + if (autoReview.toLowerCase() === 'false') { + core.info('⏭️ Auto-review is disabled, skipping code review'); + core.setOutput('diff_size', '0'); + core.setOutput('review', 'Auto-review disabled'); + return; + } // Get PR number from event if not provided const context = github.context;