#!/usr/bin/env bash # Sync the built static site to the live root in an order that avoids deploy-race # blank screens. rsync isn't atomic, so a naïve `rsync --delete` can briefly serve # a NEW index.html that points at chunks not synced yet (→ failed load), or delete # old chunks an in-flight client still needs. So the order is: # 1. new hashed chunks first, and DON'T prune old ones (14-day grace window) # 2. other static assets (version.json, icons…), pruning removed files # 3. the shell HTML — only once its chunks exist # 4. the service worker last — a returning client adopts it only after the rest # Old immutable chunks are pruned after the grace window to bound disk growth. # # NOTE: there is intentionally NO edge cache-warming. Cloudflare is DNS-only # (grey-cloud) for upbeatbytes.com — no proxy/CDN/POP — so warming would just GET # every asset from the residential origin (already µs-fast static): a no-op that # generated lots of internal request volume. Removed 2026-06-29. set -euo pipefail src="$1"; site="$2" # 1. New hashed chunks first (old ones kept — 14-day grace for in-flight clients). rsync -a "$src/_app/immutable/" "$site/_app/immutable/" # 2. Other static assets (prune removed files), then 3. the shell, then 4. the SW. rsync -a --delete \ --exclude='_app/immutable/***' --exclude='index.html' --exclude='service-worker.js' \ "$src/" "$site/" rsync -a "$src/index.html" "$site/index.html" rsync -a "$src/service-worker.js" "$site/service-worker.js" # Bound disk growth: prune immutable chunks older than the grace window. find "$site/_app/immutable" -type f -mtime +14 -delete 2>/dev/null || true