Skip to content

fix(ci): add stable storybook/ path + protect latest deploy from cleanup - #755

Closed
rubyycheung wants to merge 2 commits into
mainfrom
navi/fix/stable-latest-deploy
Closed

rubyycheung wants to merge 2 commits into
mainfrom
navi/fix/stable-latest-deploy

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

Problem

Storybook links in shared docs keep breaking because:

  1. The deploy workflow publishes to <hash>/ directories
  2. The cleanup workflow deletes old hash directories — including main deploys
  3. The latest file hash and the current main HEAD can diverge, so cleanup doesn't protect the right directory

This means any direct link like .../865f2dc/index.html?path=/docs/... stops working within days.

Fix

Deploy workflow: Also copies the Storybook build to a stable storybook/ directory. Links like studious-broccoli-o7e61n3.pages.github.io/storybook/index.html?path=/docs/core-xdsbutton--docs will always work regardless of cleanup.

Cleanup workflow: Now reads the latest file and protects that hash from deletion — prevents the race where main HEAD advances but the previous deploy gets cleaned up before the new one lands.

After merge

Shared doc links can use /storybook/ instead of /<hash>/ and they'll never break again.

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

github-actions Bot commented Mar 20, 2026 •

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

Package Size (ESM) Size (CJS) Gzipped
@xds/core 10.7KB 17.0KB 2.6KB

Accessibility Audit

Status: No accessibility violations detected.


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

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stable storybook/ and sandbox/ paths in deploy.yml — that's the real fix, and it's clean. Links to /storybook/index.html?path=... will survive cleanup forever. 👍

The cleanup workflow changes (reading the latest file and protecting that hash) should be removed though. The existing LATEST_DEPLOYED logic already does this — it finds the most recently deployed hash dir via git log on the gh-pages branch, which is strictly more reliable than reading the latest file. They'll almost always point to the same dir, and when they diverge, the git-log approach wins because it reflects what's actually on gh-pages rather than what a file claims.

Removing those two blocks from cleanup-previews.yml keeps this PR focused on the thing that actually matters: the stable paths.

— Navi (on behalf of @cixzhang)

@cixzhang

Copy link
Copy Markdown
Contributor

One more note on the deploy gap: the PR description mentions links breaking when hash directories get cleaned up, and the storybook/ path fixes that.

But there's a subtler issue worth calling out — the ~60s gap between when peaceiris/actions-gh-pages pushes to the gh-pages branch and when GitHub Pages actually starts serving the new files. During that window, /storybook/ serves the previous build (which is fine — it's just slightly stale), or 404s on the very first deploy.

This isn't something we can solve at the workflow layer. GitHub Pages doesn't expose a deploy-complete hook or status API. So don't try to engineer around it — the stable path already gives you the right tradeoff: the link always works, and the content is at most one deploy behind.

— Navi (on behalf of @cixzhang)

@rubyycheung

Copy link
Copy Markdown
Contributor Author

Good call — removed the cleanup-previews.yml changes. The existing LATEST_DEPLOYED git-log logic already covers that case. PR now only touches deploy.yml with the stable storybook/ path.

@josephfarina

Copy link
Copy Markdown
Contributor

lg2m i don't see it causing any issues

@rubyycheung
rubyycheung enabled auto-merge (squash) March 20, 2026 18:09
Two changes:
1. Deploy workflow now also copies the Storybook build to a stable
   storybook/ directory. Links like .../storybook/index.html?path=...
   will always work regardless of hash directory cleanup.

2. Cleanup workflow now reads the latest file and protects that hash
   from deletion — prevents the race where main HEAD advances but the
   previous deploy gets cleaned up before the new one lands.
The existing LATEST_DEPLOYED git-log logic already handles protecting
the most recent deploy. Keeping this PR focused on the stable storybook/ path.
@rubyycheung
rubyycheung force-pushed the navi/fix/stable-latest-deploy branch from dd7aeb6 to a84a8be Compare March 20, 2026 18:20
auto-merge was automatically disabled March 20, 2026 18:32

Pull request was closed

@cixzhang
cixzhang deleted the navi/fix/stable-latest-deploy branch April 9, 2026 14:33
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.

3 participants