fix(ci): use workflow_run pattern to restore write access for fork PR previews#43
Merged
Merged
Conversation
…n fork PRs GitHub restricts GITHUB_TOKEN to read-only for pull_request_target workflows triggered by a fork PR that modifies any workflow file (even with an explicit `contents: write` declaration). PR #40 modifies deploy.yml, causing the 403 Permission denied when peaceiris/actions-gh-pages tries to push to gh-pages. Fix: split into two workflows following the GitHub-recommended workflow_run pattern: - pr-preview.yml: build-only (contents: read), uploads dist as artifact - pr-deploy.yml: triggered by workflow_run, always gets full write access from the base repository's token regardless of fork restrictions
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job deploy-preview
fix(ci): use workflow_run pattern to restore write access for fork PR previews
Jun 11, 2026
Contributor
🔍 PR PreviewPreview URL: https://ReproNim.github.io/ReproInventory/pr-previews/pr-43/ Last updated: Thu, 11 Jun 2026 15:06:04 GMT |
likeajumprope
approved these changes
Jun 11, 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.
GitHub silently restricts
GITHUB_TOKENto read-only when apull_request_targetworkflow is triggered by a fork PR that modifies any file under.github/workflows/— regardless ofpermissions: contents: writein the workflow. PR #40 modifiesdeploy.yml, which triggered this restriction and caused thepeaceiris/actions-gh-pagespush to fail with 403.Changes
pr-preview.yml— stripped down to build-only; no longer pushes togh-pagescontents: write; now runs withcontents: readpr-preview-{N})pr-closed-{N}) to trigger cleanup downstream.github/workflows/pr-deploy.yml(new) — handles all write operations viaworkflow_runworkflow_runalways executes in the base repo's context and is not subject to the fork-workflow-file token restrictiondeploy-previewjob: downloadspr-preview-*artifact → deploys togh-pages→ posts/updates PR commentcleanup-previewjob: downloadspr-closed-*artifact → checks outgh-pages→ removes preview directory