Skip to content

Add Pull Request Previews - #1169

Merged
CryZe merged 2 commits into
LiveSplit:masterfrom
CryZe:pull-request-previews
Oct 12, 2026
Merged

CryZe merged 2 commits into
LiveSplit:masterfrom
CryZe:pull-request-previews

Conversation

@CryZe

@CryZe CryZe commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Web changes currently require a local build to review in the browser. Reuse the existing GitHub Actions web build to publish a Cloudflare Pages preview for each pull request after CI succeeds, with a stable pr-N.<project>.pages.dev address. A bot comment on the PR's Conversation page provides an Open preview link as soon as the upload succeeds; the Web preview check also links directly to it. Later builds update the same comment instead of posting another notification.

Each pull request has its own browser origin, so preview splits and layouts are isolated from production and other previews while remaining available across updates to the same PR. Previews use the optimized frontend and WebAssembly/font preloading, omit the production service worker to avoid stale builds, and can still build when GitHub contributor credits are unavailable.

flowchart LR
    PR[Open or update PR] --> CI[Existing CI build]
    CI --> Upload[Trusted preview publisher]
    Upload --> Preview[Stable URL for this PR]
    Preview --> Comment[PR conversation with Open preview link]
    Closed[Close or merge PR] --> Cleanup[Delete all builds for this PR]
Loading

Publishing runs trusted default-branch TypeScript helpers after the build, so PR code never receives the Cloudflare token. GitHub API metadata identifies the current open PR and its artifact; static-file validation and an isolated Wrangler directory prevent artifact-supplied executable code or configuration from running with deployment credentials.

Closing or merging a PR deletes all of its preview deployments, including older builds and the branch alias, retires its preview check, and updates its existing comment to say that the preview was removed. Publishing and cleanup share a per-PR concurrency group. Late publishers handle closed PRs before downloading artifacts, covering both expired artifacts and GitHub replacing a pending close job. Production deployments, other PRs, and unrelated conversation comments remain protected.

Configure repository variables CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_PAGES_PROJECT, plus the repository secret CLOUDFLARE_API_TOKEN with Pages read/write access. Hosting uses Cloudflare Pages Direct Upload on the free plan. The publisher starts once these workflows are on the default branch; until then, CI produces a downloadable preview artifact.

CryZe added 2 commits October 12, 2026 20:13
Reuse the web build from pull request CI to publish previews to Cloudflare
Pages. Give each pull request a stable branch URL and link it from a Web
preview check on the tested commit. Keep the hosting account and project
configurable so the same workflows also work in forks.

Separate building from publishing so pull request code never receives the
deployment token. Resolve the pull request and artifact through GitHub's
API, publish only the current open head after successful CI, and execute
the publisher from the default branch. Validate the static files and run
Wrangler in an isolated directory to prevent uploaded Workers, package
scripts, or configuration from running with deployment credentials. Use
native TypeScript helpers and include them in linting and type checking.

Build optimized previews with the usual WebAssembly and font preloading,
but leave out the production service worker so updates appear immediately.
Allow previews to build when contributor credits cannot be fetched. Keep
each pull request on its own origin so its saved splits and layouts remain
separate from production and other previews while surviving preview updates.

Delete every deployment for a pull request when it closes or merges,
including older builds and the branch alias. Gather all deployment pages
before deleting, protect production and other pull requests, and retire
the preview check after cleanup. Serialize publishing and cleanup for each
pull request, recheck its current state, and handle closed pull requests
before downloading artifacts so a late publisher can still clean up after
an expired artifact or a replaced pending close job.
Post a direct preview link in the pull request conversation after a
successful upload, alongside the Web preview check. Reviewers can open
the running build from the pull request itself without visiting Actions.

Update the same bot-owned comment for subsequent builds so the link stays
current without posting another notification on every update. Mark that
comment as removed when the pull request closes or merges, and avoid
posting removal comments for pull requests that never had a preview.

Grant pull request write access only to the trusted publishing and cleanup
jobs that maintain this comment. Match both the bot identity and the
preview marker before editing so other conversation comments stay intact.
@CryZe CryZe added enhancement A new feature or general improvement to LiveSplit One. CI Affects the Continuous Integration. labels Oct 12, 2026 — with ChatGPT Codex Connector
@CryZe CryZe self-assigned this Oct 12, 2026
@CryZe
CryZe marked this pull request as ready for review October 12, 2026 20:22
@CryZe
CryZe enabled auto-merge October 12, 2026 20:22
@CryZe
CryZe merged commit c8281f3 into LiveSplit:master Oct 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Affects the Continuous Integration. enhancement A new feature or general improvement to LiveSplit One.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant