GitHub mirror: the publish job takes an exact npm, and the workflow names the reviewer gate
Jonas Templestein, 2026-11-27 14:10 UTC · ad75e5ed621f5a8d15117439a7c43f8ef8dd17ca · parent 2146c01
2 files changed
M .github/workflows/mirror.yml
@@ -2,7 +2,7 @@ # github.com/iterate/kernel is a read-only mirror of https://git.iterate.com/repos/kernel, with the # same commits. This workflow runs in the mirror: it reads the source's main with no credential and # pushes it to the mirror's main. The push never forces: when the two have parted, it fails and a -# person looks. +# person looks. A ruleset of the mirror refuses a forced push to main and its deletion. # # It pushes with the deploy key in the secret MIRROR_DEPLOY_KEY, which can write to this repository # alone. The job's own token will not do: GitHub lets it push no commit that changes a workflow, and
M .github/workflows/npm-publish.yml
@@ -13,6 +13,10 @@ # its tarball on computers that have nothing of ours. `publish` hands npm the tarball that both # installs passed, with no script of it run. `check` asks npm, as this workflow, whether the # package trusts it; it writes and removes the tag `npm-publish-check` and nothing else. +# +# `publish` and `check` wait for a person: the environment `npm` has required reviewers. That gate +# is a setting on GitHub, so no commit here can remove it. Without it, a commit that edits this +# file could publish, and mirror.yml brings every commit of the source's main. on: push: branches: @@ -85,7 +89,8 @@ path: ${{ runner.temp }}/tarball - run: node .github/npm-publish.mjs install --tarball "$(ls "$RUNNER_TEMP"/tarball/*.tgz)" # npm gets the tarball that both installs passed, as it is: no script of the package runs here. - # Only a dispatch on main that names a dist-tag gets here. The environment `npm` takes main alone. + # Only a dispatch on main that names a dist-tag gets here. The environment `npm` takes main + # alone, and a reviewer of it approves the job. publish: needs: [pack, install] if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && (inputs.action == 'canary' || inputs.action == 'main') @@ -102,8 +107,9 @@ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: node-version: 26 - # trusted publishing needs npm 11.5.1 or later - - run: npm install --global npm@11 + # trusted publishing needs npm 11.5.1 or later; an exact version, because this job holds + # npm's token + - run: npm install --global npm@11.21.3 - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: tarball