Skip to content

PR previews on the modern GitHub Actions Pages source#47

Merged
cmccoy merged 1 commit into
mainfrom
claude/pr-preview-infra-njgrpu
Jun 27, 2026
Merged

PR previews on the modern GitHub Actions Pages source#47
cmccoy merged 1 commit into
mainfrom
claude/pr-preview-infra-njgrpu

Conversation

@cmccoy

@cmccoy cmccoy commented Jun 27, 2026

Copy link
Copy Markdown
Owner

What

Reworks the PR-preview setup so production stays on the modern "GitHub Actions" Pages source (actions/deploy-pages) — no branch source, and no manual Settings → Pages change required. Reviewers still get an interactive, clickable preview of each PR at https://www.cmccoy.us/pr-preview/pr-<N>/ with a sticky comment linking to it.

This supersedes the earlier gh-pages-branch approach (#46).

How it works

The Actions source serves one whole-site artifact (each deploy replaces the entire site), so previews are baked into that artifact rather than served as a separate deployment:

  1. pr-preview.yml builds each PR with --baseurl /pr-preview/pr-<N> and uses rossjrw/pr-preview-action to stage the build on a dedicated pr-previews branch under pr-preview/pr-<N>/. That branch is storage only — never the Pages source, never served directly. On PR close it removes the directory and the sticky comment.
  2. When pr-preview.yml finishes it triggers jekyll.yml via workflow_run. The deploy job always builds production from main (so PR code never reaches production paths), then its Overlay PR previews step folds the pr-preview/ tree from the pr-previews branch into _site/pr-preview/ before uploading the artifact via actions/upload-pages-artifact + actions/deploy-pages. Pushes to main redeploy the same way, so open PRs' previews survive every production deploy.

A single pages concurrency group serialises deploys so none clobber each other.

Tradeoff

Staying on the Actions source means every preview add/update/remove triggers a full production redeploy (cheap for this site), and a freshly pushed preview goes live a beat after its sticky comment posts (once the workflow_run deploy completes).

Verified locally

  • Both workflow YAMLs parse.
  • Production build keeps root-relative asset paths (/js/...); preview build emits /pr-preview/pr-1/js/....
  • CNAME lands in _site/.
  • Overlay cp nests correctly as _site/pr-preview/pr-<N>/.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DstwP2knezUiaBVqpBSZgR


Generated by Claude Code

Rework PR previews to keep production on the modern "GitHub Actions" Pages
source (actions/deploy-pages) instead of switching the Pages source to a
gh-pages branch. No manual Settings -> Pages change is required.

Because the Actions source serves a single whole-site artifact, previews are
baked into that artifact rather than served as a separate deployment:

- pr-preview.yml builds each PR with --baseurl /pr-preview/pr-<N> and uses
  rossjrw/pr-preview-action to stage the build on a dedicated pr-previews
  storage branch (never the Pages source, never served directly); the
  preview is removed and the sticky comment cleaned up when the PR closes.
- jekyll.yml deploys via actions/configure-pages + upload-pages-artifact +
  deploy-pages. It always builds production from main, then an "Overlay PR
  previews" step folds the pr-previews branch's pr-preview/ tree into
  _site/pr-preview/ before upload. It runs on push to main and, via
  workflow_run, after each preview change, so previews ship in the live
  artifact at https://www.cmccoy.us/pr-preview/pr-<N>/ and survive
  production redeploys. A single 'pages' concurrency group serialises
  deploys.

Update CLAUDE.md to document the artifact-overlay flow and its tradeoff.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DstwP2knezUiaBVqpBSZgR
@cmccoy cmccoy merged commit a4e19c4 into main Jun 27, 2026
1 check failed
cmccoy pushed a commit that referenced this pull request Jun 27, 2026
Remove the PR preview setup (PRs #46 and #47) and restore production
deployment to its original form.

- jekyll.yml: back to the plain push-to-main actions/deploy-pages workflow
  (no workflow_run trigger, no preview overlay).
- Delete pr-preview.yml.
- index.md: restore the original absolute /js/ script paths.
- CLAUDE.md: restore the original Deployment section.

Unrelated World Cup content updates are preserved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DstwP2knezUiaBVqpBSZgR
@claude claude Bot mentioned this pull request Jun 27, 2026
claude Bot added a commit that referenced this pull request Jun 27, 2026
Remove the PR preview setup (PRs #46 and #47) and restore production
deployment to its original form.

- jekyll.yml: back to the plain push-to-main actions/deploy-pages workflow
  (no workflow_run trigger, no preview overlay).
- Delete pr-preview.yml.
- index.md: restore the original absolute /js/ script paths.
- CLAUDE.md: restore the original Deployment section.

Unrelated World Cup content updates are preserved.


Claude-Session: https://claude.ai/code/session_01DstwP2knezUiaBVqpBSZgR

Co-authored-by: Claude <noreply@anthropic.com>
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