mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 03:18:54 +08:00
Add agent-approval-check composite action (#1429)
* Add agent-approval-check composite action Require N human approvals on PRs that contain agent-authored commits. Posts an agent-approval-check commit status that repos mark as a required check on protected branches. This is a sanitized port of the check Anthropic runs internally on every agent-authored PR — same detection rules, /approve <sha> comment flow, sibling-PR-same-SHA guard, and fail-closed semantics, with the Anthropic-specific path exemptions and kill-switch removed and config moved to action inputs. Co-Authored-By: Claude <noreply@anthropic.com> * Drop stray internal acronym from comment * agent-approval-check: require write-access approvers, pin deps, pagination + doc fixes 🏠 Remote-Dev: homespace * agent-approval-check: prettier 🏠 Remote-Dev: homespace * agent-approval-check: verify approver write permission via REST; commits(last:100); docstring 🏠 Remote-Dev: homespace * agent-approval-check: use headRefOid; drop pull_request_review trigger and correct threat-model docs 🏠 Remote-Dev: homespace * agent-approval-check: stale-notification wording, no-retry-on-4xx, docstring API-call count 🏠 Remote-Dev: homespace * agent-approval-check: fail-closed sibling guard on commits-ordering edge; drop stale 'reviewed' from README 🏠 Remote-Dev: homespace * agent-approval-check: drop hardcoded API-call counts from logs; clarify author write-access requirement in README 🏠 Remote-Dev: homespace * agent-approval-check: count all agent-email commits (close-reopen bypass); validate REQUIRED_APPROVALS>=1; exempt_head_branches warning 🏠 Remote-Dev: homespace --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Octavian Guzu <oct@anthropic.com>
This commit is contained in:
co-authored by
Claude
Octavian Guzu
parent
fad22eb3fa
commit
846d5d8993
@@ -0,0 +1,72 @@
|
||||
name: Agent Approval Check
|
||||
description: |
|
||||
Require N human approvals on PRs that contain agent-authored commits
|
||||
(Claude, Claude Code, or any configured bot identity). Posts an
|
||||
`agent-approval-check` commit status — mark it as a required check on
|
||||
protected branches to gate merges.
|
||||
|
||||
inputs:
|
||||
github_token:
|
||||
description: Token with statuses:write and pull-requests:write on this repo.
|
||||
default: ${{ github.token }}
|
||||
required_approvals:
|
||||
description: Number of distinct human approvals required. Must be >= 1.
|
||||
default: "2"
|
||||
agent_emails:
|
||||
description: Comma-separated committer emails treated as agent-authored.
|
||||
default: noreply@anthropic.com
|
||||
agent_logins:
|
||||
description: |
|
||||
Comma-separated GitHub logins treated as agents — a PR opened by, or an
|
||||
APPROVED review from, one of these triggers the check.
|
||||
default: claude[bot],claude-code[bot]
|
||||
excluded_approvers:
|
||||
description: Comma-separated logins whose approvals never count (e.g. rubber-stamp bots).
|
||||
default: ""
|
||||
exempt_head_branches:
|
||||
description: |
|
||||
Comma-separated glob patterns; PRs from matching head branches auto-pass.
|
||||
WARNING: leave empty — branch names are attacker-controlled, so this is
|
||||
not a safe place to encode trust.
|
||||
default: ""
|
||||
exempt_path_prefixes:
|
||||
description: Comma-separated path prefixes; PRs touching only these auto-pass.
|
||||
default: ""
|
||||
protected_bases:
|
||||
description: |
|
||||
Comma-separated base branches this check gates. Empty = the repo's
|
||||
default branch only. PRs targeting any other base are refused (no
|
||||
status posted) so a sibling PR sharing the head SHA can't get the
|
||||
shared commit stamped green.
|
||||
default: ""
|
||||
config_file:
|
||||
description: Optional path to an agent-identities YAML file (overrides the inline inputs).
|
||||
default: ""
|
||||
docs_url:
|
||||
description: Link shown in the PR comment footer.
|
||||
default: "https://github.com/anthropics/claude-code-action/tree/main/agent-approval-check"
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- run: pip install 'httpx==0.28.1' 'pyyaml==6.0.3' 'tenacity==9.1.4'
|
||||
shell: bash
|
||||
- run: python "${{ github.action_path }}/agent_approval_check.py"
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ inputs.github_token }}
|
||||
GH_REPOSITORY: ${{ github.repository }}
|
||||
GH_EVENT_NAME: ${{ github.event_name }}
|
||||
GH_EVENT_PATH: ${{ github.event_path }}
|
||||
REQUIRED_APPROVALS: ${{ inputs.required_approvals }}
|
||||
AGENT_EMAILS: ${{ inputs.agent_emails }}
|
||||
AGENT_LOGINS: ${{ inputs.agent_logins }}
|
||||
EXCLUDED_APPROVERS: ${{ inputs.excluded_approvers }}
|
||||
EXEMPT_HEAD_BRANCHES: ${{ inputs.exempt_head_branches }}
|
||||
EXEMPT_PATH_PREFIXES: ${{ inputs.exempt_path_prefixes }}
|
||||
PROTECTED_BASES: ${{ inputs.protected_bases }}
|
||||
CONFIG_FILE: ${{ inputs.config_file }}
|
||||
DOCS_URL: ${{ inputs.docs_url }}
|
||||
Reference in New Issue
Block a user