ci: gate workflows on org membership + allow claude[bot]#246
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this does
Two coupled changes to
.github/workflows/:1. Fixes the
reviewjob failure on #243. Theclaude-pr-review.ymlworkflow on PR #243 (chore(claude): learn from #242, opened byclaude[bot]) failed at theanthropics/claude-code-action@v1step withWorkflow initiated by non-human actor: claude (type: Bot). Add bot to allowed_bots list or use '*' to allow all bots.The action'sallowed_botsinput defaults to""and rejects bot triggers. Fix: passallowed_bots: "claude[bot]"on every claude-code-action step in the three Claude workflows.2. Restricts CI triggers to org members + claude[bot]. Previously any outside contributor could trigger CI by opening a PR or commenting
@claude fix. For Claude workflows that meant burning Anthropic API credits with attacker-controlled prompts under--permission-mode bypassPermissions; forcpu_test.yml/pre-commit.ymlit meant executing fork code on our runners. Six workflows now gate ongithub.<event>.<x>.author_association ∈ {OWNER, MEMBER, COLLABORATOR}OR login== 'claude[bot]'(the bot account that opens ourchore(claude): learn from #NPRs).pushandworkflow_dispatchevents are short-circuited through (already require write access).Files touched (all
.github/workflows/):claude-pr-review.yml— trust gate + loop guard tightened to exactclaude[bot]match +allowed_bots: "claude[bot]".claude-implement-fixes.yml— trust gate per event source (issue_comment,pull_request_review_comment,pull_request_review); olduser.type != 'Bot'checks dropped (subsumed) +allowed_bots: "claude[bot]".extract-claude-lessons.yml— defense-in-depth trust check appended to existing branch-name gate +allowed_bots: "claude[bot]".cpu_test.yml,pre-commit.yml— job-levelif:gating PR events only.check-pr-checklist.yml— job-levelif:gating PR events.Out of scope:
gpu_test.yml,regression_test.yml,build-docker-images.yml(schedule + workflow_dispatch only),publish-pypi.yml(tag push only). Bot allowlist isclaude[bot]only — nodependabot[bot], no*(public-repo risk per the action's docs).How it was tested
pre-commit run --files .github/workflows/*.yml— passes (yaml-lint, zizmor GitHub Actions security scanner, gitleaks, typos).if:predicates against each event payload'sauthor_association/user.loginpaths (paths confirmed against existing usages in the same files).openedshort-circuits true (auto-review of claude[bot]-opened PRs);synchronizefromclaude[bot]push evaluatessender.login != 'claude[bot]'to false → skipped.chore(claude): learn from #NPR auto-review must succeed (no more "Add bot to allowed_bots list" error).@claude fixmust triggerclaude-implement-fixes.yml; outsider@claude fixmust not.How to checkout & try? (for the reviewer)
Inspect each workflow's job-level
if:and theallowed_bots:line on eachanthropics/claude-code-action@v1step.Checklist
Generated by Claude Code