Skip to content

ci: publish PR previews as real GitHub deployments - #5371

Open
cixzhang wants to merge 1 commit into
mainfrom
feat/ci-deployment-records
Open

ci: publish PR previews as real GitHub deployments#5371
cixzhang wants to merge 1 commit into
mainfrom
feat/ci-deployment-records

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

The Storybook and Sandbox previews are already deployments in every sense except the one GitHub understands. They exist only as a bot comment, so the PR timeline shows no deployment box, the commit carries no deployment, and nothing reading the Deployments API — including the agentcloud GitHub panel — can see them at all. Vercel's Preview deployment on this same repo is a plain Deployments API call, and this makes ours the same shape.

What changes

  • deploy-preview.yml records each published preview as a GitHub Deployment on the PR's head commit, in environments Storybook and Sandbox, with environment_url set to the pr/<n>/ URLs the PR comment already links.
  • ci.yml adds headSha to pr-meta.json. deploy-preview runs in the workflow_run context and only had the 7-character hash, which cannot name a commit to the API.
  • cleanup-previews.yml marks those deployments inactive when it deletes a closed PR's pr/<n>/ directory, so no "View deployment" button outlives the site it points at.
  • redeploy-preview.yml records too. A manual re-deploy is usually a rescue after the automatic one failed, so it has to replace that failure record rather than strand it.

Three things that are load-bearing, and were not obvious

required_contexts: []. The default makes GitHub check the commit's own statuses before creating a deployment and answer 409 conflict while any check is still running — which, on a PR whose CI just finished, is most of the time.

auto_inactive: false. The default adds an inactive status to every other deployment sharing the environment name. Storybook is one environment across all PRs but each PR's URL is its own live site, so the default would silently retire every other open PR's preview on every deploy. Vercel sets it false for the same reason.

A failed push records failure, not silence (if: always()). Without it, a lost gh-pages race leaves the previous commit's green record as the newest one on the PR, pointing at content that is no longer what the PR builds. A run that never had artifacts to deploy — a cancelled CI — records nothing at all; the newer run will.

The recording is inline in both workflows rather than shared, because deploy-preview.yml deliberately checks out nothing (that is its security property) and so cannot call a local composite action. The gh-pages push loop is already duplicated between those two files for the same reason.

Test plan

actionlint on all four files: no new findings against main (the one added ci.yml line matches the unquoted $GITHUB_OUTPUT style of the four lines around it; the SC2129 finding in deploy-preview.yml is removed).

workflow_run workflows run from the default branch, so this cannot exercise itself on its own PR. Instead the two new scripts were extracted verbatim out of the workflow files and run against the real GitHub API as this account, on live PRs of this repo, then read back through the exact GraphQL document the agentcloud panel uses:

Case Result
Success on #5348 Storybook SUCCESS https://facebook.github.io/astryx/pr/5348/, Sandbox SUCCESS .../sandbox/
A second PR (#5345) in the same environments #5348's records still SUCCESSauto_inactive: false holds
Failed deploy on #5343 Storybook FAILURE, Sandbox FAILURE; the panel's wire drops the URL, so no dead button
Cleanup's retire step on #5343 both INACTIVE; the panel's wire drops them entirely
Retire step re-run, and against a nonexistent PR idempotent; guards hold under set -u (bash 5.3)
Fork PR head SHA (#5370, HelloOjasMutreja) deployment created — the head commit lives in the base repo as refs/pull/N/head, so fork previews record like any other

Every probe record was marked inactive and deleted afterwards; those PRs are back to their single Vercel Preview deployment.

Not in this PR

Previews are currently unreliable for a reason this does not touch — GitHub Pages is failing most builds because gh-pages is far over the 1 GB published-site limit. Details and numbers are in a separate write-up; a green deployment record here will still point at content Pages has not published yet.

The Storybook and Sandbox previews are already deployments in every sense
except the one GitHub understands: they were only a bot comment, so nothing
that reads deployments could see them.

deploy-preview.yml now records each published preview as a GitHub Deployment
on the PR's head commit, in environments "Storybook" and "Sandbox" — the same
shape Vercel already uses on this repo for its "Preview" environment. A lost
gh-pages race records `failure` rather than leaving the previous commit's
green record standing, and cleanup-previews.yml retires the records when it
deletes the preview so no button outlives the site it points at.
@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 23, 2026 11:40pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant