igneum/tools/site-deploy-from-mirror.sh
2026-10-07 19:58:41 +00:00

30 lines
2.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Deploy the public site from the BOX MIRROR's master (GitHub dark, 7 October 2026): a GIT-LESS export of the site tree at build/master
# (or the commit given), the site built in it (node site/build.mjs, the downloads snapshot read from the dl host), then the Vercel CLI
# from this Mac with the igneum team config (~/.config/igneum/vercel, --scope igneum; the box holds no token by R6) against the
# site project (.vercel/project.json of ~/Projects/igneum/site). Reads nothing from GitHub. Prints the commit served and the
# production URL with the UTC time; the worktree is removed after.
#
# tools/site-deploy-from-mirror.sh [<commit or ref, default build/master>]
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
REF="${1:-build/master}"
git fetch -q build master
SHA=$(git rev-parse "$REF"); SHORT=${SHA:0:8}
# a GIT-LESS export (main, 7 Oct 2026 19:4x BST: the worktree deploy G72XWh48k was BLOCKED by the team's commit-author check, which
# cannot resolve 337424239+igneum-labs@users.noreply.github.com while the GitHub account is suspended; an export carries no Git
# metadata, so the check does not apply). The deploy directory must hold no .git; the check below refuses otherwise.
W=$(mktemp -d "${TMPDIR:-/tmp}/site-deploy.XXXXXX")
trap 'rm -rf "$W"' EXIT
git archive --format=tar "$SHA" site | tar -x -C "$W"
[ -e "$W/.git" ] || [ -e "$W/site/.git" ] && { echo "the deploy directory carries a .git; refusing (the author check would block it)" >&2; exit 1; }
LINK="$HOME/Projects/igneum/site/.vercel/project.json"; [ -f "$LINK" ] || { echo "no site project link at $LINK" >&2; exit 1; }
# the Vercel project's Root Directory is "site": the deploy runs from the export's root with site/ inside it
mkdir -p "$W/.vercel"; cp "$LINK" "$W/.vercel/project.json"
echo "site export at $SHORT ($(git log -1 --format='%ci %s' "$SHA" | cut -c1-90)); no .git in $W"
( cd "$W/site" && node build.mjs ) 2>&1 | tail -3
echo "deploying $(TZ=UTC date +%H:%M:%SZ)"
OUT=$( cd "$W" && npx --yes vercel@latest --global-config "$HOME/.config/igneum/vercel" --scope igneum deploy --prod --yes 2>&1 ) || { echo "$OUT" | tail -5 >&2; exit 1; }
URL=$(echo "$OUT" | grep -oE 'https://[a-z0-9.-]*vercel\.app' | tail -1)
echo "SITE DEPLOYED commit $SHORT at $(TZ=UTC date +%H:%M:%SZ) UTC ($(TZ=Europe/London date +%H:%M) BST): $URL -> https://igneum.network"
echo "$OUT" | grep -iE "Production:|Aliased|error" | head -3