Every PR push gets a live preview link that opens on the feature that changed, with its state kept in the PR comment itself.

The problem

Reviewing UI from a diff is guesswork. Even for engineers it means pull, install, run, then click around looking for the screen that changed. Designers and PMs mostly don’t do it at all, so they see the change after it ships.

Preview deploys fix that, but the obvious version brings its own mess: a new bot comment on every push, a link that opens the app’s home page, a failed build that leaves no link at all, and a database or cache somewhere to remember the last good URL.

What I concluded

Deploy every push to a static host under its own path, and keep one PR comment that both shows the link and stores the workflow’s state.

  push ─▶ announce ─▶ build + upload ─▶ notify
           │           pr/<n>/<sha>/      │
           ▼                              ▼
   "Building…" + last link        new link, deep-linked
           (same comment, edited in place)

The comment is the database

GitHub doesn’t render HTML comments, but the API returns them as text. So the comment carries a marker to find it and a hidden tag with the last deploy URL. The next run reads the tag, and while it builds it keeps the previous link visible. If the build fails, that link stays up. There’s no storage to run.

const MARKER = "<!-- canary-deploy -->";
const mine = comments.find((c) => c.body?.includes(MARKER));
const prev = mine?.body?.match(/<!-- prev-canary=(.*?) -->/)?.[1];
const body = `${MARKER}\n<!-- prev-canary=${url} -->\n` +
  `[View canary](${url})`;
// update `mine` if it exists, otherwise create it

Land inside the feature

After the deploy, the workflow counts the PR’s changed files per view directory and links to the route of the one touched most. The guess is sometimes wrong, so a line like canary-path: /orders/new in the PR description overrides it. Strip HTML comments from the description first, so the template’s example line doesn’t match.

Let the PR lifecycle clean up

Builds are grouped per PR with cancel-in-progress, so a new push kills the stale build and different PRs never cancel each other. The notify job skips cancelled runs, or a cancelled build would overwrite the live comment with a failure. When the PR closes, a cleanup job deletes its whole prefix, so no cron job is needed. The SHA path gets immutable cache headers because its contents never change.

Rules

  • One comment, edited in place. Find it by a hidden marker, never post a second one.
  • Keep the last good link visible. During a build and after a failure.
  • Deep-link to the change. Guess from changed files, let the author override.
  • Cancel stale builds per PR. And don’t let a cancelled run touch the comment.
  • Close the PR, delete the preview. The lifecycle is the garbage collector.

What you get

Reviewers click one link and land on the screen that changed, on every push, with nothing to install. The whole thing runs on any static host and one workflow file, with no extra infrastructure.

Related: Storybook tests