From 0bc500a6f972ce14a8446d47033ed5fba0182873 Mon Sep 17 00:00:00 2001 From: Wynne Pirini Date: Wed, 18 Nov 2026 09:06:08 +1300 Subject: [PATCH] fix(ci): remove the workflow-level permissions cap that kills fork PR runs Docker publish and NS8 module publish never start on pull requests from forks. The run is created with ZERO jobs, so there is no log and no annotation, and the only visible trace is a check suite concluding startup_failure or failure. CAUSE. #231 added a workflow-level `permissions: contents: read` to both files for least privilege. That is the only change to either file between the last green fork run and the first red one, and removing it restores them. WHAT IT IS NOT, which is why this took a week. It is not "workflows that declare packages: write are refused on forks". At the last green fork run (main 98b5799, 2026-11-06) the job-level build: {contents: read, packages: write} was already present and fork PRs passed for months. The declaration is necessary for the break but it is not what changed, so toning it down would not have been the fix. It is not "a job escalating above a workflow-level cap" either. Audit has a top-level `read-all` and its scorecard job escalates to security-events: write and id-token: write, and Audit ran SUCCESS with 3 jobs on fork head fe75122, the same head where these two workflows produced zero jobs. So the failing shape is narrower: a workflow-level cap plus a job asking for PACKAGES write. THE SIGNATURE, and why it proves the failure is at expansion. On head fe75122: CLA Assistant success jobs=1 CodeQL success jobs=2 CI success jobs=1 Audit success jobs=3 Docker publish failure jobs=0 NS8 module publish failure jobs=0 The decisive detail is ns8-module.yml: its `validate` job needs only contents: read, and its `build` job is the one asking for packages: write. Yet `validate` never ran either, because the whole workflow produced zero jobs. So the run is rejected before any job exists. That is a workflow-expansion failure, not a build failure wearing a strange exit code. THE FIX. Remove the workflow-level block from both files and leave a comment in its place saying there is deliberately none, and why, so nobody re-adds it as a tidy-up. Least privilege is not weakened. The repository default is already `read` (default_workflow_permissions=read), so a job without an explicit block still gets read, and every job in both files declares its own permissions anyway. What is lost is redundancy, not a guarantee. Deliberately not done: moving the packages: write work into a separate off-PR job. That is the better end state if the PR and publish paths ever need to differ more than they do, but it is a larger diff solving a problem this does not. UNPROVEN, stated plainly. There is no GitHub documentation citation here for packages-write behaviour on forks under an explicit cap. The evidence is the A/B above, a perfect correlation across every fork head, and a counterexample that narrows the rule. If fork runs still produce zero jobs after this, the rule is wider and this is not the whole story. Diff is comments plus the removal of two lines in each file. No other workflow or permission was touched. --- .github/workflows/docker-publish.yml | 22 ++++++++++++++++------ .github/workflows/ns8-module.yml | 23 ++++++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2b572967..428ede1e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -34,12 +34,22 @@ concurrency: group: docker-publish-${{ github.ref }} cancel-in-progress: true -# Read-only by default. Each job below asks for what it needs on top: build -# pushes to GHCR (packages: write), release creates the GitHub Release -# (contents: write). -permissions: - contents: read - +# There is deliberately NO workflow-level `permissions:` block here. +# +# One was added in #231 for least privilege. It broke every run from a fork +# pull request: the run failed during workflow expansion, so it was created with +# ZERO jobs and produced no log and no annotation. Removing it restored them. +# +# The combination is what matters, not either half. The build job below asks for +# `packages: write` to push to GHCR, and a fork pull request can never be granted +# a write token. On its own that is harmless, because GitHub downgrades it and +# the job runs. Underneath a workflow-level cap, the same request was observed to +# make GitHub reject the run before any job existed. Evidence, the full A/B and +# the counterexample that narrows this are in the PR that removed it. +# +# Least privilege is not weakened by leaving this out: every job below declares +# its own permissions, and the repository default is already `read`. Do not +# re-add this as a tidy-up; that is exactly how the fork runs were lost. env: REGISTRY: ghcr.io # Hardcoded lowercase — GHCR tags reject the repo's actual "Calnode/calnode" diff --git a/.github/workflows/ns8-module.yml b/.github/workflows/ns8-module.yml index b9d03642..202f8162 100644 --- a/.github/workflows/ns8-module.yml +++ b/.github/workflows/ns8-module.yml @@ -35,11 +35,24 @@ concurrency: group: ns8-module-publish cancel-in-progress: false -# Read-only by default. Only the build job writes, to push the module image -# to GHCR (packages: write), and it says so itself. -permissions: - contents: read - +# There is deliberately NO workflow-level `permissions:` block here. +# +# One was added in #231 for least privilege. It broke every run from a fork +# pull request: the run failed during workflow expansion, so it was created with +# ZERO jobs and produced no log and no annotation. Removing it restored them. +# The symptom is worth knowing, because it does not look like a permissions +# problem: the `validate` job below only needs `contents: read`, and it never ran +# either, because nothing runs when the whole run is rejected. +# +# The combination is what matters, not either half. The build job asks for +# `packages: write` to push the module image to GHCR, and a fork pull request can +# never be granted a write token. On its own that is harmless, because GitHub +# downgrades it and the job runs. Underneath a workflow-level cap, the same +# request was observed to make GitHub reject the run before any job existed. +# +# Least privilege is not weakened by leaving this out: every job below declares +# its own permissions, and the repository default is already `read`. Do not +# re-add this as a tidy-up; that is exactly how the fork runs were lost. jobs: validate: runs-on: ubuntu-latest