Build PR previews without maintainer approval - #1806
Merged
Conversation
Contributor
|
Thanks! Nice way to preview changes |
Contributor
There was a problem hiding this comment.
Pull request overview
Reworks PR previews to build untrusted contributions without maintainer approval, then validate and deploy artifacts through a trusted workflow.
Changes:
- Builds and uploads preview artifacts for every PR.
- Validates artifacts before Cloudflare deployment.
- Removes the former fork-approval workflow and reuses one preview comment.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.github/workflows/pr-preview-check.yml |
Builds the preview artifact without secrets. |
.github/workflows/fork-preview-deploy.yml |
Removes the approval-gated fork workflow. |
.github/workflows/cloudflare-preview.yml |
Resolves, validates, deploys, and comments on previews. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+326
to
+328
| const previewUrl = ( | ||
| process.env.PREVIEW_ALIAS_URL || process.env.PREVIEW_DEPLOYMENT_URL || '' | ||
| ).trim(); |
Comment on lines
+163
to
+169
| - name: Download preview site | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: pr-preview-site | ||
| path: ${{ runner.temp }}/pr-preview-site | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| run-id: ${{ github.event.workflow_run.id }} |
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.
Fork previews currently pause each fork update in
fork-preview-protectionuntil a maintainer approves the environment deployment. This creates repeated approval requests, delays contributor feedback, and fills the Actions UI with waiting jobs.This change removes the preview-specific maintainer approval step. Every PR builds RDoc in a read-only workflow that has no secrets. A trusted
workflow_runmatches the_siteartifact to the current PR head and rejects non-static Pages controls.sequenceDiagram actor Author as PR author participant PR as Pull request participant Build as Build PR Preview<br/>Untrusted, no secrets participant Artifact as GitHub artifact store participant Deploy as Deploy PR Preview<br/>Trusted participant Cloudflare as Cloudflare Pages Author->>PR: Open, update, or reopen the PR PR->>Build: Start pull_request workflow Build->>Build: Checkout PR code at the exact head SHA Build->>Build: Setup Ruby Build->>Build: Build site into _site alt The build produces an artifact Build->>Artifact: Upload preview site for one day else The build fails before upload Note over Build,Artifact: No preview artifact is available end Build-->>Deploy: workflow_run completed, success or failure Deploy->>Deploy: Resolve current pull request and artifact Deploy->>PR: Match one open PR to the exact head SHA Deploy->>Artifact: Match one artifact from this exact run alt The PR, SHA, or artifact is not current and valid Deploy--xDeploy: Stop before Cloudflare secrets else The candidate is current Artifact-->>Deploy: Download preview site Deploy->>Deploy: Validate preview site as safe static files Deploy->>PR: Confirm pull request head again alt The site is invalid or the PR head changed Deploy--xDeploy: Stop before deployment else The site is safe and the PR is current Deploy->>Deploy: Prepare trusted Wrangler directory Note over Deploy,Cloudflare: Cloudflare secrets are supplied only for this call Deploy->>Cloudflare: Deploy to the PR-number-preview branch Cloudflare-->>Deploy: Return an HTTPS pages.dev URL Deploy->>PR: Update preview comment after one final head and URL check Note over PR: Reuse one marked comment with the preview URL and commit SHA end endContributors now receive an updated preview after each commit that produces a preview artifact. Per-PR concurrency cancels older work, and one bot comment points to the latest successful preview. Maintainers no longer open individual environment deployments or receive repeated preview approval requests.
The trusted workflow exposes the Cloudflare token only to the deployment step. It does not download the PR repository or run PR code. GitHub's separate public-fork policy can still hold workflows from contributors who are new to GitHub. Existing PRs can retain the old MATZBOT comment once. Later deployments update only the new GitHub Actions comment.