ci: publish PR previews as real GitHub deployments - #5371
Open
cixzhang wants to merge 1 commit into
Open
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Previewdeployment on this same repo is a plain Deployments API call, and this makes ours the same shape.What changes
deploy-preview.ymlrecords each published preview as a GitHub Deployment on the PR's head commit, in environmentsStorybookandSandbox, withenvironment_urlset to thepr/<n>/URLs the PR comment already links.ci.ymladdsheadShatopr-meta.json.deploy-previewruns in theworkflow_runcontext and only had the 7-character hash, which cannot name a commit to the API.cleanup-previews.ymlmarks those deploymentsinactivewhen it deletes a closed PR'spr/<n>/directory, so no "View deployment" button outlives the site it points at.redeploy-preview.ymlrecords too. A manual re-deploy is usually a rescue after the automatic one failed, so it has to replace thatfailurerecord 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 answer409 conflictwhile any check is still running — which, on a PR whose CI just finished, is most of the time.auto_inactive: false. The default adds aninactivestatus to every other deployment sharing the environment name.Storybookis 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.ymldeliberately 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
actionlinton all four files: no new findings againstmain(the one addedci.ymlline matches the unquoted$GITHUB_OUTPUTstyle of the four lines around it; theSC2129finding indeploy-preview.ymlis removed).workflow_runworkflows 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:Storybook SUCCESS https://facebook.github.io/astryx/pr/5348/,Sandbox SUCCESS .../sandbox/SUCCESS—auto_inactive: falseholdsStorybook FAILURE,Sandbox FAILURE; the panel's wire drops the URL, so no dead buttonINACTIVE; the panel's wire drops them entirelyset -u(bash 5.3)HelloOjasMutreja)refs/pull/N/head, so fork previews record like any otherEvery probe record was marked inactive and deleted afterwards; those PRs are back to their single Vercel
Previewdeployment.Not in this PR
Previews are currently unreliable for a reason this does not touch — GitHub Pages is failing most builds because
gh-pagesis 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.