fix: grant pull-requests write permission in release workflow#28
Open
ericcrosson-bitgo wants to merge 1 commit intomasterfrom
Open
fix: grant pull-requests write permission in release workflow#28ericcrosson-bitgo wants to merge 1 commit intomasterfrom
ericcrosson-bitgo wants to merge 1 commit intomasterfrom
Conversation
1b47c22 to
9072180
Compare
@semantic-release/github's success step fetches commits from PRs referenced in release commit messages. Without explicit permissions, the GITHUB_TOKEN lacks pull_requests=read scope, causing 404 errors on PRs from the upstream repo's history. Ticket: DX-916
9072180 to
c600869
Compare
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.
Problem
The release workflow has been failing at the very last step — after the tag and GitHub release are already successfully created — with a 404 from the GitHub API.
Failing run: https://github.com/BitGo/semantic-release-github-actions/actions/runs/25228201691/job/73976939543
What goes wrong
@semantic-release/githubruns asuccessstep after publishing the release. It parses all commit messages in the release, extracts PR numbers from merge commit messages (e.g.Merge pull request #41 from ...), and posts a comment on each PR. That requirespull_requests=readat minimum — the API response even tells us:The failing request:
PR semantic-release-action#41 doesn't exist in this fork. It exists in the upstream
semantic-release-action/github-actionsrepo. The fork inherited upstream commit history, including merge commit messages that reference upstream PR numbers. When@semantic-release/githubtries to look them up here, it gets 404 and throws, failing the job.Why there was no explicit permissions block
The workflow has no
permissions:declaration, so it inherits the repository default. For org repos with restricted default token permissions,pull-requestsis not granted, causing the 404.Fix
Add an explicit
permissionsblock to thereleasejob:contents: writewas already implicitly needed (tag + release creation was working), but making it explicit is correct practice.issues: writeandpull-requests: writeare what@semantic-release/githubneeds to comment on issues and PRs after a release.Why not just disable PR comments?
An alternative would be setting
successComment: falsein.releaserc.json. That would also stop the crash, but it silently degrades functionality — downstream repos that use this action and have valid PRs would lose release comments. Granting the permission is the right fix: it restores the intended behavior rather than working around missing access.Verification
After merging, the next push to
mastershould produce a release run that completes all steps includingsuccesswithout a 404. The full expected log sequence ends with:Checklist
pull-requestspermission onGITHUB_TOKEN).releaserc.jsonunchanged — no features disabledTicket: DX-916