Skip to content

fix: use pull_request_target for PR preview workflow to grant write access on fork PRs#42

Merged
likeajumprope merged 2 commits into
mainfrom
copilot/fix-deploy-preview-job-again
Jun 11, 2026
Merged

fix: use pull_request_target for PR preview workflow to grant write access on fork PRs#42
likeajumprope merged 2 commits into
mainfrom
copilot/fix-deploy-preview-job-again

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

GitHub silently downgrades GITHUB_TOKEN to read-only when a pull_request workflow is triggered from a fork, ignoring any permissions: contents: write declaration. This caused the deploy-preview job to fail with a 403 when trying to push to gh-pages.

Changes

  • pull_requestpull_request_target: Runs in the base repo context, so GITHUB_TOKEN respects the declared contents: write permission regardless of PR origin.
  • Explicit PR head checkout: Since pull_request_target checks out the base branch by default, added ref: ${{ github.event.pull_request.head.sha }} to build the PR's actual code.

⚠️ Security note: pull_request_target with an explicit fork checkout runs untrusted build scripts with write-token access. This is a standard pattern for public OSS PR previews — no sensitive secrets are used in the build step and GITHUB_TOKEN scope is limited to this repo.

Copilot AI changed the title [WIP] Fix failing GitHub Actions job deploy-preview fix: use pull_request_target for PR preview workflow to grant write access on fork PRs Jun 11, 2026
Copilot AI requested a review from likeajumprope June 11, 2026 14:32
@likeajumprope likeajumprope marked this pull request as ready for review June 11, 2026 14:37
@likeajumprope likeajumprope merged commit 3b566d7 into main Jun 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants