Skip to content

Preview Playground PR builds from artifacts#3700

Draft
adamziel wants to merge 1 commit into
adamziel/pr-preview-build-workflowfrom
adamziel/pr-query-preview
Draft

Preview Playground PR builds from artifacts#3700
adamziel wants to merge 1 commit into
adamziel/pr-preview-build-workflowfrom
adamziel/pr-query-preview

Conversation

@adamziel
Copy link
Copy Markdown
Collaborator

@adamziel adamziel commented May 28, 2026

What changed

Adds the runtime and server pieces for artifact-backed WordPress Playground PR previews via ?playground-pr=<number>.

This PR is stacked on top of #3703, which only adds the CI workflow that produces playground-pr-preview-<pr>-<sha> artifacts.

This PR adds:

  • same-origin /pr-previews/<pr>/current.json and /pr-previews/<pr>/<sha>/... routing backed by GitHub Actions artifacts
  • server-side artifact download/extract/cache logic
  • a stable preview bootstrap service worker that maps static requests to the artifact-backed virtual path and imports the PR build's own sw.js
  • website boot logic for ?playground-pr=<number>
  • remote URL parameter preservation so the iframe registers the same preview service worker
  • service-worker preview path mapping/bypass behavior
  • tests for preview URL parsing, SW URL selection, path mapping, and PHP routing headers

Why

This lets maintainers preview Playground PR builds without deploying PR files to production paths. The browser still uses same-origin URLs, which is required for a root-scoped service worker, while the backing files come from GitHub Actions artifacts.

How to test locally

First, run the CI workflow from #3703 for a PR so the playground-pr-preview-<pr>-<sha> artifact exists. Then run a PHP-routed local server with GITHUB_TOKEN so /pr-previews/... requests execute the artifact proxy instead of falling back to static index.html.

Testing

  • npm exec nx test playground-website -- --run
  • npm exec nx test playground-remote -- --run
  • npm exec nx typecheck playground-website
  • npm exec nx typecheck playground-remote
  • npm exec nx lint playground-website
  • npm exec nx lint playground-remote
  • php packages/playground/website-deployment/tests.php
  • npm exec nx build playground-website

@adamziel adamziel force-pushed the adamziel/pr-query-preview branch from 1988bc4 to de61288 Compare May 28, 2026 23:17
@adamziel adamziel changed the base branch from trunk to adamziel/pr-preview-build-workflow May 28, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant