Skip to content

Declare the Merge-Bot's Actions Event Policy in repo-config - #4637

Merged
ptr727 merged 4 commits into
developfrom
actions-event-policy
Dec 6, 2026
Merged

ptr727 merged 4 commits into
developfrom
actions-event-policy

Conversation

@ptr727

@ptr727 ptr727 commented Dec 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Since 2026-12-02 GitHub blocks pull_request_target on every public repository that has no Actions event policy of its own. So every public fleet repository's merge-bot caller failed at startup and no Dependabot or codegen pull request auto-merged. repo-config/ now declares the policy that lets the merge-bot run, and configure.sh manages it.

  • Payload. repo-config/actions-policies.json holds one policy. It is active, scoped by conditions.workflow_path.include to .github/workflows/merge-bot-pull-request.yml alone, with allowed_events: ["pull_request_target"]. So no other workflow regains the trigger.
  • Apply. The new group runs after the workflow token defaults. It matches each declared policy by name, creates it where absent, updates it by the id the live list gives where it differs, and writes nothing where it matches. Each write is confirmed by reading that policy back by its id. A policy the payload does not declare is never touched. The pre-flight validates the payload and reads the live list before any group writes.
  • Check. Each declared policy must exist and match. An undeclared live policy is a warning, since it may restrict events.
  • Every repository. The group applies to private repositories too, so a visibility change never breaks the merge-bot (Decision ptr727, 2026-12-05, on Allow pull_request_target for the Merge-Bot Under GitHub's New Default Policy on Public Repositories #4633).
  • Duplicate names refuse. Two live policies under one declared name stop both modes, naming the one to delete by hand. ruleset_id warns and takes the first instead. The difference is deliberate, since a stray same-named policy can restrict events.
  • API shape. The list endpoint omits each policy's conditions and rules, so both modes compare against the single read. Every call sends X-GitHub-Api-Version: 2026-03-10.
  • read_back_settles now passes trailing arguments to its read function. Its one existing caller passes none.
  • Docs. repo-config/README.md, docs/repo-config.md, OPERATIONS.md, and AUDIT.md name the new group.

Closes #4633

Verification

  • Live trial on this repository. The same policy was created here first. A fresh merge-bot run then started and succeeded, and pull_request CI and Dependabot runs outside the policy's path still ran.
  • Fleet rollout. The policy now exists on all 25 non-archived fleet repositories, created by a one-off script outside this change. A single read of each confirmed its scope and events.
  • configure.sh check ptr727/ProjectTemplate release reports the new group as matching the live policy.
  • Tests. tests/test_configure_actions_policies.py adds 24 offline cases with only gh stubbed. They cover the payload contract, the live read's refusals, create, update, match, read-back, the check paths, and the cmd_apply pre-flight aborting before any write. The test_configure*.py suite runs 216 tests. Its three AuditDiscussionsCase errors are a missing markdown_it module on the local host, in code this change does not touch.
  • shellcheck, shfmt, markdownlint, ruff, mypy, and the prose gate pass.

Local Review Findings

Three recorded local-strict-review passes ran. The first two raised nine findings, all fixed. The edit budget was spent with one finding open:

  • introduced, minor: repo-config/configure.sh line 819, in apply_project's comment, says resolving the node id there would abort the run "after the four earlier groups had already been written". Six groups now run before it. The number should be dropped rather than corrected.

Fleet state: the policy now exists on every fleet repository, private ones and the two public repositories without a merge-bot included, created by the same one-off script and read back by id. So configure.sh check finds it everywhere.

This pull request adds comment lines in configure.sh and the new test, so it carries the comments label.

🤖 Generated with Claude Code

ptr727 and others added 4 commits December 5, 2026 20:48
GitHub blocks pull_request_target workflows on a public repository with no Actions event policy of its own, which fails the merge-bot workflow at startup.
configure.sh now declares the policy in actions-policies.json, applies it by name on every repository, and checks it, warning on an undeclared live policy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Apply and check matched a declared policy by the first live entry of its name, so a duplicate left the judged policy to list order. The live read now refuses that case and names the policy to delete by hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Read back only a policy a write touched, by the id the POST response or the listed id gave, so a create never depends on the list catching up and a match makes no read-back.
Capture each write's response instead of printing it, add one name-to-id helper, and add offline tests for the payload contract, the live read, apply, and check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
read_back_settles now hands its trailing arguments to the read function, so apply reads back one policy by id with no global or wrapper.
Drop the redundant empty-id check after the POST, correct the README on what the policy list carries, and test the apply pre-flight and the argument pass-through.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings December 6, 2026 05:05
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Dec 6, 2026
@coderabbitai

coderabbitai Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4de0886 and 1955e95.

Files selected for processing: 8

  • AUDIT.md
  • OPERATIONS.md
  • docs/repo-config.md
  • repo-config/README.md
  • repo-config/actions-policies.json
  • repo-config/configure.sh
  • tests/test_configure_actions_policies.py
  • tests/test_configure_project.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A moderate active issue remains because the paginated Actions policies response is not fully aggregated, causing valid repositories with more than 30 policies to fail in both apply and check modes.

1 open issue
What changed in this PR

Adds fleet-wide GitHub Actions event-policy management so the merge-bot can use pull_request_target safely.

Changes:

  • Declares the merge-bot policy and implements idempotent apply/check handling.
  • Adds offline tests for validation, reads, writes, read-back, and wiring.
  • Updates repository configuration, operations, and audit documentation.
File Description
tests/​test_configure_project.py Updates configuration-group wiring tests for the new Actions policies group.
tests/​test_configure_actions_policies.py Adds offline tests covering Actions policy validation, reads, writes, read-back, checking, and pre-flight behavior.
repo-config/​README.md Documents the Actions policy payload and management behavior.
repo-config/​configure.sh Implements Actions policy validation, application, checking, read-back, and configuration wiring.
repo-config/​actions-policies.json Declares the path-scoped merge-bot pull_request_target policy.
OPERATIONS.md Updates operational guidance for applying repository configuration.
docs/​repo-config.md Updates repository configuration guidance for Actions policies.
AUDIT.md Adds Actions event policies to audit coverage.

Review effort: Lite

Comment thread repo-config/configure.sh Resolved
@codecov

codecov Bot commented Dec 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.47%. Comparing base (5c797e0) to head (1955e95).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4637   +/-   ##
========================================
  Coverage    78.47%   78.47%           
========================================
  Files           58       58           
  Lines        17873    17873           
========================================
  Hits         14026    14026           
  Misses        3847     3847           
Flag Coverage Δ
python-3.13 78.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Dec 6, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Dec 6, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited. More included reviews will be available in 49 minutes.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit a685c52 into develop Dec 6, 2026
18 checks passed
@ptr727
ptr727 deleted the actions-event-policy branch December 6, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants