Push the upstream mirror with a workflow-scoped token, and report a failed run
Requested by Jonathan · project thread
Closes #227
Before: the daily mirror-upstream.yml run pushed with GITHUB_TOKEN, which GitHub refuses for any commit that edits .github/workflows/. Every time upstream touched a workflow file the mirror stopped moving (runs of 23, 24 and 28 September), and because nothing watched a failed scheduled run, pre-flight PRs were reviewed against a four-day-old base before anyone noticed.
After: the checkout uses the MIRROR_PUSH_TOKEN repository secret (a fine-grained token on this repo with Contents and Workflows write, added by the owner on 2026-10-05) and falls back to the default token if the secret is missing. After the push the job checks that mirror/upstream-main equals upstream main, and any failed run opens one issue, or comments on it if it is already open, with a link to the run.
How: token: ${{ secrets.MIRROR_PUSH_TOKEN || github.token }} on actions/checkout, so the push step's credential changes and nothing else does. The new "Confirm" step compares commit ids rather than trusting the push's exit code. The report step finds its issue by an HTML marker and only among issues github-actions[bot] opened, the same pattern as upstream-sync-reminder.yml. It needs issues: write, added to the workflow's permissions.
Evidence
- The comment of 2026-09-29 on #227 tabulates eight runs: the push was refused exactly when its range edited a workflow file, and a push of that same range with a workflow-scoped credential went through.
- Each step's
runblock passesbash -n, and the workflow parses as YAML. - I dispatched this branch's workflow as run 37302502048, and it succeeded: it checked out with the new token, pushed, and passed the new "Confirm" step. Today's range has no workflow-file change, so this proves the token works but not the Workflows permission. The first upstream workflow edit after merge is the real test, and if it fails the new issue will say so.
- I did not exercise the failure-report step. It only runs when a run fails.
Not changed
- The push itself, its lease, and the schedule.
upstream-sync-reminder.yml.
Summary by CodeRabbit
- Chores
- Automated mirror updates now verify that the mirrored branch matches upstream.
- When a mirror update fails, an issue is created or an existing matching issue is updated to report the failure.