Add contents: write permission to release workflow
#544
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.
Problem
The release workflow failed during tag creation with the following error: https://github.com/api3dao/signed-api/actions/runs/20229930044/job/58070438146#step:10:29
Root Cause
The issue stems from the change in
main.ymlthat removedtoken: ${{ secrets.GH_ACCESS_TOKEN }}fromactions/checkout. This token is necessary because it works similarly togit clone https://${GH_USERNAME}:${GH_TOKEN}@github.com/api3dao/signed-api.gitwhere Git saves the token credentials for subsequent operations.Later in the workflow, we define
GH_ACCESS_TOKENintag-and-release, but that's only used for Octokit actions within the createGithubRelease function. However, this function also executes nativegit pushcommands, which need the saved credentials. Without the token inactions/checkout, thesegit pushoperations fail.Solution
Added
contents: writepermission to thetag-and-releasejob. This allows the defaultGITHUB_TOKENto have write access, eliminating the need for the customGH_ACCESS_TOKENin the checkout step.Testing
Confirmed the fix by testing all alternatives in a test repository: https://github.com/bdrhn9/test-release