Skip to content

fix(deploy): clean deploys, PR previews at /pr/<number>/, stable sandbox URL - #916

Merged
cixzhang merged 1 commit into
mainfrom
navi/fix/deploy-cleanup
Mar 27, 2026
Merged

cixzhang merged 1 commit into
mainfrom
navi/fix/deploy-cleanup

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Problem

Three issues with the current gh-pages deploy:

  1. storybook/ has 2,656 accumulated files (vs ~192 per build — 14x bloat). keep_files: true means old content-hashed chunks are never removed.

  2. /sandbox/ is deleted daily by the cleanup workflow then recreated by deploy with the wrong basePath. It was listed as a "stale root-level item" alongside old Storybook files like favicon.svg.

  3. PR preview dirs use commit hashes (/<7-char-hex>/) which are hard to identify and require GitHub API calls to match to PRs during cleanup.

Solution

deploy.yml — switch to keep_files: false

Each deploy is now a clean slate. Before deploying, the workflow clones gh-pages and preserves /pr/ and /reports/ dirs, then copies them into the fresh deploy/ directory.

  • Sandbox builds with basePath=/sandbox (stable, self-contained URL)
  • Landing page links directly to storybook/index.html and sandbox/index.html — no JS resolution needed
  • No more hash-versioned main deploy (/<hash>/) — stable paths are the canonical URLs

ci.yml — PR previews at /pr/<number>/

PR previews now deploy to /pr/<number>/ instead of /<commit-hash>/. Benefits:

  • Easy to identify which PR a directory belongs to
  • Stable URL across force-pushes (same PR number, content gets overwritten)
  • Trivial cleanup — just match PR numbers against open PRs list

cleanup-previews.yml — simplified

  • Delete /pr/<number>/ dirs for closed/merged PRs
  • Delete all legacy 7-char hex directories (one-time migration)
  • Stop deleting /sandbox/ — it's no longer stale, it's a stable deploy target
  • No more complex hash-dir retention logic (main HEAD, latest deployed, etc.)

gh-pages layout after this PR

/storybook/    — stable (always latest main, clean each deploy)
/sandbox/      — stable (always latest main, clean each deploy)
/pr/<number>/  — PR previews (cleaned when PR closes)
/reports/      — vibe test reports (preserved across deploys)
/assets/       — landing page CSS
/index.html    — landing page
/latest        — short hash pointer

Supersedes most of #913 (that PR can be narrowed to just the BuildStatus component if still wanted).

…box URL

Three workflow changes that fix gh-pages bloat and broken sandbox URLs:

**deploy.yml — clean deploys (keep_files:false)**
- Switch from keep_files:true to keep_files:false — each deploy is a
  clean slate instead of accumulating stale content-hashed assets forever
- Preserve /pr/ and /reports/ dirs by cloning gh-pages before deploying
- Build sandbox with basePath=/sandbox (stable, self-contained URL)
- Landing page links directly to /storybook/ and /sandbox/ (no JS
  resolution needed, no dependency on hash dirs)
- Remove hash-versioned main deploy (/<hash>/) entirely — stable paths
  are the canonical URLs now

**ci.yml — PR previews at /pr/<number>/**
- Deploy PR previews to /pr/<number>/ instead of /<commit-hash>/
- Cleaner namespace: easy to identify, easy to clean up
- PR preview URLs in comments now use /pr/<number>/ paths

**cleanup-previews.yml — simplified cleanup**
- Delete /pr/<number>/ dirs for closed PRs (simple number match vs API)
- Delete all legacy 7-char hex directories (one-time migration)
- No longer deletes /sandbox/ (was being nuked daily by old cleanup!)
- No more complex hash-dir retention logic (main HEAD, latest deployed)

Fixes: storybook/ had 2,656 accumulated files (vs ~192 per build, 14x
bloat). sandbox/ was deleted daily by cleanup then recreated by deploy
with wrong basePath. Both issues are resolved.
@cixzhang
cixzhang requested a review from josephfarina as a code owner March 27, 2026 03:54
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 27, 2026
@cixzhang
cixzhang merged commit 6a56638 into main Mar 27, 2026
11 checks passed
@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

Package Size (ESM) Size (CJS) Gzipped
@xds/core 11.2KB 17.7KB 2.8KB

Accessibility Audit

Status: No accessibility violations detected.


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

@cixzhang
cixzhang deleted the navi/fix/deploy-cleanup branch April 9, 2026 14:32
cixzhang added a commit that referenced this pull request Apr 26, 2026
…box URL (#916)

Three workflow changes that fix gh-pages bloat and broken sandbox URLs:

**deploy.yml — clean deploys (keep_files:false)**
- Switch from keep_files:true to keep_files:false — each deploy is a
  clean slate instead of accumulating stale content-hashed assets forever
- Preserve /pr/ and /reports/ dirs by cloning gh-pages before deploying
- Build sandbox with basePath=/sandbox (stable, self-contained URL)
- Landing page links directly to /storybook/ and /sandbox/ (no JS
  resolution needed, no dependency on hash dirs)
- Remove hash-versioned main deploy (/<hash>/) entirely — stable paths
  are the canonical URLs now

**ci.yml — PR previews at /pr/<number>/**
- Deploy PR previews to /pr/<number>/ instead of /<commit-hash>/
- Cleaner namespace: easy to identify, easy to clean up
- PR preview URLs in comments now use /pr/<number>/ paths

**cleanup-previews.yml — simplified cleanup**
- Delete /pr/<number>/ dirs for closed PRs (simple number match vs API)
- Delete all legacy 7-char hex directories (one-time migration)
- No longer deletes /sandbox/ (was being nuked daily by old cleanup!)
- No more complex hash-dir retention logic (main HEAD, latest deployed)

Fixes: storybook/ had 2,656 accumulated files (vs ~192 per build, 14x
bloat). sandbox/ was deleted daily by cleanup then recreated by deploy
with wrong basePath. Both issues are resolved.
cixzhang added a commit that referenced this pull request Jun 21, 2026
…box URL (#916)

Three workflow changes that fix gh-pages bloat and broken sandbox URLs:

**deploy.yml — clean deploys (keep_files:false)**
- Switch from keep_files:true to keep_files:false — each deploy is a
  clean slate instead of accumulating stale content-hashed assets forever
- Preserve /pr/ and /reports/ dirs by cloning gh-pages before deploying
- Build sandbox with basePath=/sandbox (stable, self-contained URL)
- Landing page links directly to /storybook/ and /sandbox/ (no JS
  resolution needed, no dependency on hash dirs)
- Remove hash-versioned main deploy (/<hash>/) entirely — stable paths
  are the canonical URLs now

**ci.yml — PR previews at /pr/<number>/**
- Deploy PR previews to /pr/<number>/ instead of /<commit-hash>/
- Cleaner namespace: easy to identify, easy to clean up
- PR preview URLs in comments now use /pr/<number>/ paths

**cleanup-previews.yml — simplified cleanup**
- Delete /pr/<number>/ dirs for closed PRs (simple number match vs API)
- Delete all legacy 7-char hex directories (one-time migration)
- No longer deletes /sandbox/ (was being nuked daily by old cleanup!)
- No more complex hash-dir retention logic (main HEAD, latest deployed)

Fixes: storybook/ had 2,656 accumulated files (vs ~192 per build, 14x
bloat). sandbox/ was deleted daily by cleanup then recreated by deploy
with wrong basePath. Both issues are resolved.
cixzhang added a commit that referenced this pull request Jun 21, 2026
…box URL (#916)

Three workflow changes that fix gh-pages bloat and broken sandbox URLs:

**deploy.yml — clean deploys (keep_files:false)**
- Switch from keep_files:true to keep_files:false — each deploy is a
  clean slate instead of accumulating stale content-hashed assets forever
- Preserve /pr/ and /reports/ dirs by cloning gh-pages before deploying
- Build sandbox with basePath=/sandbox (stable, self-contained URL)
- Landing page links directly to /storybook/ and /sandbox/ (no JS
  resolution needed, no dependency on hash dirs)
- Remove hash-versioned main deploy (/<hash>/) entirely — stable paths
  are the canonical URLs now

**ci.yml — PR previews at /pr/<number>/**
- Deploy PR previews to /pr/<number>/ instead of /<commit-hash>/
- Cleaner namespace: easy to identify, easy to clean up
- PR preview URLs in comments now use /pr/<number>/ paths

**cleanup-previews.yml — simplified cleanup**
- Delete /pr/<number>/ dirs for closed PRs (simple number match vs API)
- Delete all legacy 7-char hex directories (one-time migration)
- No longer deletes /sandbox/ (was being nuked daily by old cleanup!)
- No more complex hash-dir retention logic (main HEAD, latest deployed)

Fixes: storybook/ had 2,656 accumulated files (vs ~192 per build, 14x
bloat). sandbox/ was deleted daily by cleanup then recreated by deploy
with wrong basePath. Both issues are resolved.
cixzhang added a commit that referenced this pull request Aug 5, 2026
…an commit (#4718)

Every push to main has had its Deploy job cancelled for ~a day (15-min job
timeout). The deploy job cloned all of gh-pages and `cp -r`'d the entire
/pr/ tree forward on every push. With ~52 live previews (>1GB, ~40k files)
the clone + two copies blew the 15-min budget before the publish step ever ran.

The cost was O(all live previews) per deploy — a full local copy of the tree
was required because peaceiris `force_orphan:true` publishes whatever is in
publish_dir.

Fix: build the single orphan commit ourselves and reuse /pr/ & /reports/ by
SHA instead of copying them:
  - --filter=blob:none + sparse-checkout materializes ONLY the stable paths
    (storybook/ sandbox/ assets/ + root files). /pr/ & /reports/ (the >1GB of
    preview blobs) are never fetched or written — they stay in the index as
    skip-worktree entries.
  - clean-replace the stable paths so superseded content-hashed assets don't
    accumulate (keeps what keep_files:false originally fixed, #916).
  - git write-tree rebuilds the full tree from the index (pr/ & reports/ reused
    by SHA); git commit-tree with no parent produces a single orphan commit —
    the same clean-slate history force_orphan gave us (#2239/#2238), now without
    a full local copy of gh-pages.
  - push with --force-with-lease + retry to stay safe against concurrent
    gh-pages writers (other main deploys, PR-preview pushes).

Deploy time is now O(1) in preview count. compact-gh-pages.yml stays as the
weekly history backstop.

Note: deploy-preview.yml still full-clones gh-pages per preview push (same
root pattern, not yet at the timeout) — worth the same treatment as a follow-up.
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