Repository navigation
Autorelease: run on pull_request_target so fork PRs get a write token - #2
Merged
Merged
Conversation
The Autorelease workflow failed on projectsyn#6 (run 41829920010) with: HttpError: Resource not accessible by integration POST /repos/projectsyn/issues/6/comments -> 403 Root cause: the job runs on `pull_request`. That PR was opened from the bacluc-agent fork, and GitHub always hands such runs a read-only GITHUB_TOKEN with no secrets ("GITHUB_TOKEN Permissions ... Issues: read" and "Secret source: None" in the run log). The permissions key cannot lift that restriction for fork runs, so every API write done by projectsyn/pr-label-tag-action fails: the PR comment (issues), the release tag (contents) and the "Release" workflow dispatch (actions). PRs on branches inside the repository (for example the Renovate ones, or component-solution-backup#1 which released v0.1.0) are unaffected, which is why the same workflow file works in the other component repositories. Switch the trigger to `pull_request_target`, which runs the base branch's workflow with a write token even for public forks, and declare the three permissions the action needs so the job no longer depends on the repository's default workflow permissions. The job only reads the PR metadata from the event payload and never checks out or executes code from the PR, which is what makes pull_request_target safe here. Consequence: runs for PRs from contributors without write access now need a maintainer to approve them, as they carry a write token.
This was referenced Nov 4, 2026
Owner
Author
|
Test evidence, all of it from this fork (same file contents as upstream, plus restricted default workflow permissions, which is the harsher case):
Two things this PR's variant got wrong and later commits fixed: All three branches here are staging. The upstream-facing change is one commit on |
3 tasks done
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
Autorelease failed on projectsyn#6:
run 41829920010 / job 126574135507
Root cause
create-release-tagruns onpull_request. projectsyn/component-solution-backup#6 was opened from this fork, and GitHub always givespull_requestruns from forks a read-onlyGITHUB_TOKENwith no secrets — visible in the run log:projectsyn/pr-label-tag-actionwrites through the API (issues.createComment,git.createRef,actions.createWorkflowDispatch), so the first write — the "Merging this PR will releasev0.1.1" comment — fails with the 403 above. Thepermissions:key cannot lift that limit for fork runs, and a PAT secret is not reachable either (no secrets in fork runs).Same-repo PRs are unaffected, which is why the identical workflow file works in the other component repos: component-solution-backup#1 released
v0.1.0and component-argocd#327 got its release comment.Fix
Trigger the workflow on
pull_request_targetinstead, which runs the base branch's workflow with a write token even for public forks, and state the permissions the action needs explicitly instead of relying on the repository default. The job never checks out or executes PR code — it only reads the PR metadata from the event payload — sopull_request_targetis safe here. The action itself is payload-driven (payload.pull_request,payload.action,pull_request.merged/merge_commit_sha), all of whichpull_request_targetprovides, so no action change is needed.Single commit
31ef186on branchfix-autorelease-fork-pr-permissions:.github/workflows/auto-release.yaml(+9/-1).Notes for upstream
fix-autorelease-fork-pr-permissionsneeds a PR intoprojectsyn/component-solution-backup:master— see class: fix multi instance behaviour projectsyn/component-solution-backup#6 for the tracking comment. The same latent bug exists in every component repo generated fromprojectsyn/commodore-component-template({{ cookiecutter.slug }}/.github/workflows/auto-release.yaml); fixing it there is deliberately out of scope of this PR.pull_request_targetuses the workflow file from the base branch, so nothing changes for existing PRs until this is merged.Test evidence
See the next comment / https://github.com/bacluc-agent/component-solution-backup/pull/... (in-progress: verifying the release comment, tag creation and
Releasedispatch on this fork, which is where the fixed workflow actually runs).