From 91d2ef3fcf12a6117e16fccee1f597bff7f3c6ef Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 15:16:06 +0000 Subject: [PATCH 1/2] 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; From 9d3fe9dc926765ebee3224267653651cf80ff37c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 15:16:39 +0000 Subject: [PATCH 2/2] Update package-lock.json after npm install --- package-lock.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3531bd0..aa46abf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -98,7 +98,6 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1189,7 +1188,6 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.2.tgz", "integrity": "sha512-/g2d4sW9nUDJOMz3mabVQvOGhVa4e/BN/Um7yca9Bb2XTzPPnfTWHWQg+IsEYO7M3Vx+EXvaM/I2pJWIMun1bg==", - "peer": true, "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.1.0", @@ -2003,7 +2001,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.25", "caniuse-lite": "^1.0.30001754",