ci: grant write permission to catalog generator job - #35
Merged
Conversation
The auto-commit step in catalog.yml failed with a 403 because the default GITHUB_TOKEN is read-only. Scoping contents:write to the single job that pushes keeps other jobs (and future additions) on the safer read-only default. Refs: https://github.com/no-magic-ai/no-magic/actions/runs/24640876735
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
Update Catalogworkflow, which has been failing on every push tomainthat touches0[1-4]-*/*.pyorscripts/generate_catalog.py. The generator step succeeds, but the subsequentgit pushfails with HTTP 403 because the defaultGITHUB_TOKENis read-only.Reference failing run: https://github.com/no-magic-ai/no-magic/actions/runs/24640876735/job/72044527262
Root cause
Token permissions in the failing run (from the workflow log header):
The
catalog.ymlworkflow regeneratesdocs/catalog.jsonand commits it back tomain. Without an explicitpermissions:block, GitHub Actions grants the workflow read-only token scope, so the finalgit pushis rejected:Change
Grant
contents: writescoped to thegeneratejob only:Why job-level, not workflow-level
Declaring
permissions:at the job level rather than at the top of the workflow keeps any future jobs on the default read-only scope. Principle of least privilege — only the job that actually pushes gets write access.Recursion safety
The workflow auto-commits
docs/catalog.json, but the trigger path filter is limited to:docs/catalog.jsonis not in that list, so the bot's commit will not re-trigger the workflow. No loop risk.Files changed
.github/workflows/catalog.yml— +2 lines (job-scopedpermissions: contents: write)Test plan
main.0[1-4]-*/*.pyorscripts/generate_catalog.pyshould triggerUpdate Catalogand succeed through the push step.docs/catalog.jsoncommits cleanly.Out of scope
catalog.jsonfrom a committed artifact to a build-time artifact (would eliminate the need to push from CI entirely, but changes the site-build contract — separate PR).