fix(actions): grant deploy.yaml contents:write so build-number action can push tag#751
Merged
Conversation
Follow-up to #750. The consolidated deploy.yaml introduced an explicit permissions block: permissions: contents: read packages: write That tightening broke the very first step. `einaregilsson/build-number@v2` tracks the monotonic build counter by creating a git ref `refs/tags/build-number-NNN` via the GitHub REST API. With contents:read the call returns: Failed to create new build-number ref. Status: 403, err: null, result: { message: 'Resource not accessible by integration' } Every push to main since 5:17 UTC has failed at the Generate Build Number step, skipping image build + k8s deploy. Restoring contents:write here matches the previous repo-default token permissions (which is what deploy.yaml was running under for years before #750 added the explicit block).
Germey
approved these changes
May 16, 2026
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.
What broke
In #750 I added an explicit
permissions:block todeploy.yamlto follow least-privilege practice:That broke the very first step of the workflow:
einaregilsson/build-number@v2tracks the monotonic build counter by creating a git refrefs/tags/build-number-NNNvia the GitHub REST API. Withcontents: readthe call gets:Failed run for reference: 25953665320 (deploy on merge commit
a34575c4).Result: every push to
mainsince 05:17 UTC has failed the Generate Build Number step, which skips image build + k8s deploy. Production is still serving the previous image (build-number-760) until this lands.What this PR does
One-line semantic change —
contents: read→contents: write:This matches what the workflow was running under for years before #750 (the repo's default
GITHUB_TOKENpermissions). The explicit block keeps everything else locked down (actions,issues,pull-requests, etc. all stay implicit-none).Why not replace einaregilsson/build-number@v2
Considered. Replacing it (e.g. with a
git rev-list --count HEADstyle scheme, oractions/github-scriptwriting the ref) is a bigger surgery that:deploy/production/*.yamldepends on via${TAG}substitution indeploy/run.sh.So: smallest fix that restores production. The action upgrade can be tackled separately if/when we want to drop the legacy
::set-env/ACTIONS_ALLOW_UNSECURE_COMMANDSrequirement.Verification
python3 -c "import yaml; print(yaml.safe_load(open('.github/workflows/deploy.yaml'))['permissions'])"→{'contents': 'write', 'packages': 'write'}✓Rollback
If this somehow makes deploys worse, revert is a 1-line edit back to
contents: read— but that re-bricks the build counter. Cleaner rollback isgit revert <this-PR-sha>which restores PR #750's broken state, so don't do that — just iterate forward.This pull request was generated and committed by the GitHub Copilot coding agent on behalf of @CQUPTQiCu.