Skip to content

fix(ci): enable Actions PR creation so mcp-toplist-badge.yml's refresh actually runs (#273) - #290

Merged
cdeust merged 1 commit into
mainfrom
fix-toplist-badge-pr-permission-273
Jul 30, 2026
Merged

fix(ci): enable Actions PR creation so mcp-toplist-badge.yml's refresh actually runs (#273)#290
cdeust merged 1 commit into
mainfrom
fix-toplist-badge-pr-permission-273

Conversation

@cdeust

@cdeust cdeust commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #273. mcp-toplist-badge.yml's monthly refresh reached Open refresh PR
and failed there — GitHub Actions is not permitted to create or approve pull requests — because this repo's Settings → Actions → General → "Allow
GitHub Actions to create and approve pull requests"
was unchecked. That
blocks PR creation itself, a stronger failure than the workflow's own
comment anticipated (which only explained why a GITHUB_TOKEN-authored PR's
own checks don't start, not why creation could be refused outright).

Fix

Root cause fixed at the repo-policy layer (issue AC1(a)), not in the
workflow — its secrets.BADGE_REFRESH_TOKEN || secrets.GITHUB_TOKEN fallback
was already correct and needed no logic change:

gh api -X PUT repos/cdeust/Cortex/actions/permissions/workflow \
  -f default_workflow_permissions=read \
  -F can_approve_pull_request_reviews=true

Verified live:

$ gh api repos/cdeust/Cortex/actions/permissions/workflow
{"default_workflow_permissions":"read","can_approve_pull_request_reviews":true}

The workflow's comment is updated to document both distinct failure modes
(checks-don't-start vs. creation-refused) and the fix, plus the
BADGE_REFRESH_TOKEN PAT fallback for if the org/repo policy is ever reset
(repo transfer, policy audit, etc.) — so a future recurrence is diagnosable
from the file alone without re-deriving the two-mode analysis.

AC2 evidence — real workflow_dispatch run, conclusion: success

First verification attempt was dispatched against my fix branch by mistake
(--ref fix-toplist-badge-pr-permission-273), which made
peter-evans/create-pull-request open the PR against that branch instead of
main (PR #288) — closed + branch deleted immediately, no code or repo-state
effect, documented so it isn't mistaken for a second incident.

Correct run, dispatched on main (the branch the setting change already
applies to, being a repo-level policy, not code):

  • Run: https://github.com/cdeust/Cortex/actions/runs/30528267921
    completed / success
  • Log excerpt:
    Attempting creation of pull request
    Created pull request #289 (cdeust:chore/mcp-toplist-badge-refresh => main)
    pull-request-operation = created
    
  • Opened PR: chore: refresh MCP Toplist rank badge #289 — a real content
    diff (assets/badge-mcp-toplist.svg, +7/-7, current upstream rank/percentile),
    the routine monthly refresh, not a synthetic no-op. Left open for the
    maintainer/coordinator to review and merge (not merged by me, per this
    task's "do not merge" instruction) — its own CodeQL checks passed;
    Lint/Test/etc. (the pull_request-triggered required checks) did not
    start, which is the documented, pre-existing, separate limitation of a
    GITHUB_TOKEN-authored PR (failure mode 1 in the updated comment) — not a
    defect this issue's AC asks me to close, and no BADGE_REFRESH_TOKEN PAT
    secret exists in this repo to avoid it (gh secret list — empty).

AC3 evidence — no stray branch left behind

$ gh api repos/cdeust/Cortex/branches/chore%2Fmcp-toplist-badge-refresh

returned 404 before either verification run (the earlier failing run's
stray branch had already been deleted per #273's own report). After my two
dispatches: the first (wrong-base) attempt's PR #288 was closed and its
branch deleted immediately; the second (correct) run's branch now backs the
still-open, real-content PR #289 — not stray, by the same definition #273
uses (a stray branch is one pushed with no accompanying PR).

Blast radius / stakes

  • Stakes: Low — a docs-comment + CHANGELOG edit, plus a repo Settings
    toggle (no application code, no schema, no runtime behavior change for any
    consumer-facing tool).
  • Strategy: direct (big-bang) — a repo policy flag and a comment edit have
    no partial-rollout notion; this matches Move 3's "infra change, no
    user-visible behavior" case.
  • Rollback: gh api -X PUT repos/cdeust/Cortex/actions/permissions/workflow -F can_approve_pull_request_reviews=false reverts the setting instantly (RTO: seconds, RPO: none — it's a policy flag, not data); git revert reverts the comment/CHANGELOG edit. Both tested paths (the PUT command above was run and re-verified via GET in this PR; git revert is a standard, always-available Git operation for a 2-file diff).

Completion Ledger (§13.2)

Path introduced Evidence
Repo setting can_approve_pull_request_reviews: true gh api repos/cdeust/Cortex/actions/permissions/workflowtrue, quoted above
Updated workflow comment (two failure modes + fix + PAT fallback) actionlint -color .github/workflows/mcp-toplist-badge.yml → exit 0; reviewer read
No script/test logic changed git diff --stat shows only the workflow comment + CHANGELOG; pytest tests_py/scripts/test_refresh_mcp_toplist_badge.py → 51 passed, unchanged
CHANGELOG entry (§H4) This PR's CHANGELOG.md diff, ### Fixed section
Real workflow_dispatch run succeeds (AC2) run 30528267921, conclusion: success, log quoted above
PR opened or "no changes" reported (AC2) PR #289 opened with real content diff
No stray branch left behind (AC3) branches/chore%2Fmcp-toplist-badge-refresh 404 pre-run; post-run branch backs open PR #289, not stray

Rules compliance

Rule Status Evidence
§4 size limits N/A no file exceeds limits; +21/-4 lines total
§8 sourced constants pass no new constants introduced
§9 dead code pass no code added/removed, comment-only + CHANGELOG
§12 mutation testing N/A no load-bearing logic changed (YAML comment + prose only)
§13 Completion Ledger pass table above
§14 boy-scout pass see report below; no unaddressed seen defects
§15 no deviation pass all 3 AC items satisfied in full, no descoping

Test-count docs

Not touched — no test added, removed, or modified; tests_py/scripts/test_refresh_mcp_toplist_badge.py's 51 tests are unchanged and pass. .bestpractices.json/CLAUDE.md/CONTRIBUTING.md/README.md/docs/ASSURANCE-CASE.md/assets/badge-tests.svg counts are unaffected.

Closes #273.

Root cause of #273: the repo's "Allow GitHub Actions to create and
approve pull requests" setting (Settings -> Actions -> General) was
unchecked, which blocks peter-evans/create-pull-request from creating
a PR at all -- a stronger failure than the workflow's comment
anticipated (it only described why a GITHUB_TOKEN-authored PR's own
checks wouldn't start, not why creation itself could be refused).

Fixed at the repo-policy layer via the GitHub API
(actions/permissions/workflow, can_approve_pull_request_reviews=true)
-- not in the workflow file, which already had the correct
BADGE_REFRESH_TOKEN||GITHUB_TOKEN fallback and needed no logic change.
The workflow comment now documents both distinct failure modes plus
the fix and the PAT fallback for if the policy is ever reset.

Verified: actionlint clean, the 51 tests_py/scripts/test_refresh_mcp_
toplist_badge.py tests pass unchanged (no script logic touched), no
stray chore/mcp-toplist-badge-refresh branch exists.

Refs #273

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cdeust
cdeust force-pushed the fix-toplist-badge-pr-permission-273 branch from 46c2b87 to 2b086e4 Compare July 30, 2026 08:59
@cdeust
cdeust merged commit 768ab09 into main Jul 30, 2026
19 checks passed
@cdeust
cdeust deleted the fix-toplist-badge-pr-permission-273 branch July 30, 2026 10:38
cdeust added a commit that referenced this pull request Jul 30, 2026
PRs opened with the default GITHUB_TOKEN do not trigger workflows (GitHub's
documented behaviour, and noted in this repo's own CHANGELOG for exactly this
workflow), so #289's required CI checks never started and it sat
MERGEABLE/BLOCKED with only the 4 CodeQL checks reported. An empty commit
pushed from a user credential starts them. #290 fixed the repo setting that
prevents Actions from opening these PRs at all; this unblocks the one already
open.
cdeust added a commit that referenced this pull request Jul 30, 2026
* chore: refresh MCP Toplist rank badge

* chore: trigger CI on this badge-refresh PR

PRs opened with the default GITHUB_TOKEN do not trigger workflows (GitHub's
documented behaviour, and noted in this repo's own CHANGELOG for exactly this
workflow), so #289's required CI checks never started and it sat
MERGEABLE/BLOCKED with only the 4 CodeQL checks reported. An empty commit
pushed from a user credential starts them. #290 fixed the repo setting that
prevents Actions from opening these PRs at all; this unblocks the one already
open.

---------

Co-authored-by: cdeust <3167767+cdeust@users.noreply.github.com>
Co-authored-by: cdeust <cdeust@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: mcp-toplist-badge.yml cannot open its refresh PR — repo forbids Actions from creating PRs

1 participant