Skip to content

ci: grant publish job contents:write for lockfile auto-commit#86

Merged
phramz merged 1 commit into
mainfrom
fix-publish-perms
Apr 27, 2026
Merged

ci: grant publish job contents:write for lockfile auto-commit#86
phramz merged 1 commit into
mainfrom
fix-publish-perms

Conversation

@phramz

@phramz phramz commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a job-level `permissions:` block to `publish` granting `contents: write`, while leaving the workflow-level `contents: read` default for every other job. Minimum-privilege: only the `publish` job needs write access (to push the `bundles.lock` auto-update commit back to main).

Why

Post-merge run for #85 (`24988341535`) revealed:

step result
Promote to GHCR ✅ pass — redis 6.3.0 bundles pushed
Update lockfile ✅ pass — local `bundles.lock` updated
Commit lockfile (if changed) fail — `git push` rejected with HTTP 403

```
fatal: unable to access 'https://github.com/buildrush/setup-php/': The requested URL returned error: 403
```

Root cause: the workflow-level `permissions:` block (lines 14–17) grants only `contents: read`. The `publish` job inherits that and the `GITHUB_TOKEN` it uses for the `actions/checkout` (`token: ${{ secrets.GITHUB_TOKEN }}`) cannot push.

After this change, `publish` runs end-to-end on the next push to main, the `chore(lock): update bundles.lock from pipeline ` commit lands, and the in-tree lockfile rejoins the GHCR registry state.

State of main right now

Once this PR merges and the next `publish` job runs on main, the lockfile catches up and the regression resolves.

Test plan

  • CI on this PR: lint + unit + 20 pipeline + 4 smoke all green (no functional change).
  • Post-merge on main: `publish` step `Commit lockfile (if changed)` succeeds.
  • Post-publish: `gh api 'repos/buildrush/setup-php/contents/bundles.lock?ref=main' --jq .content | base64 -d | grep -c '"ext:redis:6.3.0:'` returns 10.

Related: #38 (redis bump, PR #76), #83 (smoke-action self-containment, PR #85).

The publish job's 'Commit lockfile (if changed)' step failed with HTTP 403
on git push because the workflow-level permissions block grants only
contents:read. Override at the job level so only publish gets write
access; other jobs (lint, unit, pipeline, smoke-action) keep the
read-only default.

Symptom seen post-merge of #85: redis 6.3.0 bundles successfully pushed
to GHCR, but the bundles.lock commit could not land on main, leaving the
in-tree lockfile out of sync with the GHCR registry.
@phramz
phramz merged commit 7703e3a into main Apr 27, 2026
28 checks passed
@phramz
phramz deleted the fix-publish-perms branch April 27, 2026 10:38
phramz added a commit that referenced this pull request Apr 27, 2026
…89)

Manually-regenerated bundles.lock from `phpup lockfile-update` against
ghcr.io/buildrush. Replaces the 8 existing `ext:redis:6.2.0:{8.1..8.4}:*`
entries with the corresponding 6.3.0 entries, and adds 2 new
`ext:redis:6.3.0:8.5:*` entries (8.5 was previously excluded for
redis pre-#76).

Brings main back to a fully consistent state — catalog, lockfile, and
GHCR all agree on redis 6.3.0 — completing the work started in #76.

The non-redis line-level churn in this diff is in-entry digest/spec_hash
refresh from the multiple publish runs that fired during the chain of
fixes (#85, #86, #87, #88). Bundle keys themselves are unchanged
outside of redis. Per internal/testsuite/runner.go:345-346, manifest
digests are non-reproducible across pushes because meta.json carries a
build-time timestamp; this is expected behavior, not a regression.

Why this is committed by hand rather than auto-committed by the publish
job: the publish job's git push is rejected by the main-branch ruleset
("Changes must be made through a pull request"). A follow-up will
either switch the auto-commit to a bot-PR flow or grant the publish
identity a ruleset bypass; until then, version-bump PRs require this
manual lockfile-update PR step.
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.

1 participant