Repository navigation
fix(deploy): stop copying PR previews forward; publish via cheap orphan commit - #4718
Merged
Merged
Conversation
…an commit
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
enabled auto-merge (squash)
August 5, 2026 03:59
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 branch was successfully deployed
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.
Problem
Every push to
mainhas had its Deploy job cancelled for ~a day — it hits the 15-minute job timeout in the preview-preservation logic and never reaches the publish step. The gh-pages site (Storybook/Sandbox) has been stale since the last success.Timeline from a representative failed run (
deployjob):cp(Terminate orphan process: pid … (cp))Root cause
The job cloned all of gh-pages and
cp -r'd the entire/pr/tree forward on every push. Measured today:/pr/is >1 GB across ~52 live previews and 38,986+ files (the tree API response is truncated — actual is larger). That's a ~1.2 GB clone plus two full copies of ~40k files per deploy — an O(all live previews) cost that crossed the 15-min budget (durations had been climbing: 8m → 27m → 44m → 50m → 1h59m before the hard failures).The copy existed because peaceiris
force_orphan:truepublishes whatever is inpublish_dir, so the full tree had to be materialized locally.Fix
Build the single orphan commit ourselves and reuse
/pr/&/reports/by SHA instead of copying them:--filter=blob:none+sparse-checkoutmaterializes only the stable paths (storybook/ sandbox/ assets/+ root files)./pr/&/reports/blobs are never fetched or written — they stay in the index as skip-worktree entries.keep_files:falseoriginally fixed in fix(deploy): clean deploys, PR previews at /pr/<number>/, stable sandbox URL #916).git write-treerebuilds the full tree from the index (/pr/&/reports/reused by SHA);git commit-treewith no parent yields a single orphan commit — the same clean-slate historyforce_orphangave us ([codex] Compact gh-pages history #2239 / Trim gh-pages artifact history from default clones #2238), now without a full local copy of gh-pages.--force-with-lease+ retry to stay safe against concurrent gh-pages writers (other main deploys, PR-preview pushes).Three constraints, all preserved
Validation
Verified the load-bearing mechanism (sparse-checkout +
write-treepreserving excluded paths as an orphan commit) in a self-contained local git repo:pr/&reports/are absent from the worktree;force_orphan);pr/<n>/survived.Also:
bash -nclean on bothrun:scripts; YAML parses.Follow-up (not in this PR)
deploy-preview.ymlstill full-clones gh-pages on every PR-preview push (same root pattern, just not at the timeout yet). Worth the same--filter=blob:none/sparse treatment.cc @thedjpetersen — this reworks the
force_orphanpath you added in #2239; the single-orphan-commit history behavior is intentionally preserved, just produced via plumbing so it no longer requires copying the whole preview tree.