ci(pr-rebase): do not force-push a head the run token cannot get checked (#2082) #2085

Merged
jaylouisw merged 1 commit from fix/1119-0402 into main 2026-11-19 04:38:05 +00:00
Owner

Fixes #2082

What was wrong. pr-rebase.yml force-pushes a pull-request branch with TOKEN: ${{ secrets.FORGEJO_TOKEN || secrets.GITHUB_TOKEN || github.token }}. When the secret is absent that resolves to the run token, and on this instance a push made with the run token lands on the branch but raises no pull_request event - no run is created for the head it mints (/actions/tasks has no row at all, so it was never created, not cancelled). That head replaces one that had checks, sits on current main so no later pass revisits it, and can never be armed, because merge_when_checks_succeed is evaluated against an empty status set. The permanent 0-status pull request in #2082. The stuck heads carry exactly the committer this file sets, packetforge-bot@users.noreply.git.jayw.uk.

auto-rebase.yml learned this on 2026-11-18 and refuses the push; pr-rebase.yml - the job that fires on every push to every pull request - did not.

What changed.

  • pr-rebase.yml: RUN_TOKEN: ${{ github.token }} is carried in the rebase step, and a pass holding nothing but the run token now leaves the branch as the author wrote it, before paying for a checkout, and says why with the remedy (a user token in FORGEJO_TOKEN). Behind main is a pull request that can still merge on the checks it has; a head nothing checks cannot merge at all.
  • scripts/check-rebase-push-guard.js: audits every workflow as text for a force-push of a pull-request branch (git push --force-with-lease ... refs/heads/) whose step has no RUN_TOKEN, no TOKEN/RUN_TOKEN comparison, or a comparison that does not stop the pass.
  • test/rebase-push-guard.test.js: the three bad shapes on fixtures, a commented-out guard, and both real maintenance workflows.

Verified. node scripts/syntax-check.js: 438 files, all OK. node scripts/run-tests.js --filter=rebase-push-guard: 6 assertions, 0 failed (the real-workflow assertion fails on origin/main with E_NO_RUN_TOKEN at pr-rebase.yml:140). bash -n on the extracted step. Disk-hygiene and closed-issues suites still green (12 and 36 assertions).

Not fixed here. The server-side reason a run token push raises no event (act_runner / Forgejo pull_request fan-out) is outside this repository; this change stops the queue being drained into that hole. Setting FORGEJO_TOKEN to a user token remains the cure for the rebases themselves.

Fixes #2082 **What was wrong.** `pr-rebase.yml` force-pushes a pull-request branch with `TOKEN: ${{ secrets.FORGEJO_TOKEN || secrets.GITHUB_TOKEN || github.token }}`. When the secret is absent that resolves to the run token, and on this instance a push made with the run token lands on the branch but raises no `pull_request` event - no run is created for the head it mints (`/actions/tasks` has no row at all, so it was never created, not cancelled). That head replaces one that had checks, sits on current `main` so no later pass revisits it, and can never be armed, because `merge_when_checks_succeed` is evaluated against an empty status set. The permanent 0-status pull request in #2082. The stuck heads carry exactly the committer this file sets, `packetforge-bot@users.noreply.git.jayw.uk`. `auto-rebase.yml` learned this on 2026-11-18 and refuses the push; `pr-rebase.yml` - the job that fires on *every* push to *every* pull request - did not. **What changed.** - `pr-rebase.yml`: `RUN_TOKEN: ${{ github.token }}` is carried in the rebase step, and a pass holding nothing but the run token now leaves the branch as the author wrote it, before paying for a checkout, and says why with the remedy (a user token in `FORGEJO_TOKEN`). Behind main is a pull request that can still merge on the checks it has; a head nothing checks cannot merge at all. - `scripts/check-rebase-push-guard.js`: audits every workflow as text for a force-push of a pull-request branch (`git push --force-with-lease ... refs/heads/`) whose step has no `RUN_TOKEN`, no `TOKEN`/`RUN_TOKEN` comparison, or a comparison that does not stop the pass. - `test/rebase-push-guard.test.js`: the three bad shapes on fixtures, a commented-out guard, and both real maintenance workflows. **Verified.** `node scripts/syntax-check.js`: 438 files, all OK. `node scripts/run-tests.js --filter=rebase-push-guard`: 6 assertions, 0 failed (the real-workflow assertion fails on `origin/main` with `E_NO_RUN_TOKEN` at pr-rebase.yml:140). `bash -n` on the extracted step. Disk-hygiene and closed-issues suites still green (12 and 36 assertions). **Not fixed here.** The server-side reason a run token push raises no event (act_runner / Forgejo pull_request fan-out) is outside this repository; this change stops the queue being drained into that hole. Setting `FORGEJO_TOKEN` to a user token remains the cure for the rebases themselves.
ci(pr-rebase): do not force-push a head the run token cannot get checked (#2082)
All checks were successful
CI / Classify the change (pull_request) Successful in 11s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 5s
CI / Server smoke test (pull_request) Successful in 10s
CI / Docker build (pull_request) Successful in 21s
CI / Test (Node 20) (pull_request) Successful in 52s
CI / Test (Node 18) (pull_request) Successful in 1m1s
CI / Test (Node 22) (pull_request) Successful in 54s
CI / Arm auto-merge (pull_request) Successful in 3s
77396d4071
pr-rebase.yml is the maintenance job that fires on every push to every pull
request, and it force-pushed with whatever its token expression resolved to -
the run's own `github.token` when the FORGEJO_TOKEN secret is absent. A push
made with that token lands on the branch but raises no `pull_request` event, so
no run is created for the head it mints. That head replaces one that had checks,
sits on current `main` so no later pass revisits it, and can never be armed:
`merge_when_checks_succeed` is evaluated against a status set that is empty.
That is the permanent 0-status pull request in #2082, and the stuck heads carry
the committer identity this file sets (`packetforge-bot@users.noreply.git.jayw.uk`).

auto-rebase.yml already refuses this push for the same reason; pr-rebase.yml now
does too, before it pays for a checkout: RUN_TOKEN is carried in the step, and a
pass holding nothing but the run token leaves the branch as the author wrote it
and says why, with the remedy (a user token in FORGEJO_TOKEN).

The rule is held down by scripts/check-rebase-push-guard.js, which reads the
workflows as text (no YAML dependency here) and reports a force-push of a
pull-request branch whose step has no RUN_TOKEN, no TOKEN/RUN_TOKEN comparison,
or a comparison that does not stop the pass. test/rebase-push-guard.test.js
covers those three shapes on fixtures and audits both real workflows.
forgejo-actions scheduled this pull request to auto merge when all checks succeed 2026-11-19 04:20:27 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!2085
No description provided.