Files
docs/scripts/publish-site.sh
T
jeffryandClaude Opus 5 e7d7cc9451 publish-site: push HEAD:site from a throwaway orphan
The local branch survived the worktree and collided on the second run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 10:23:14 -04:00

22 lines
762 B
Bash
Executable File

#!/usr/bin/env bash
# Put dist/ on the `site` branch, which holds build output and nothing else.
# git-sync follows that branch; there is no image and no rollout.
set -euo pipefail
cd "$(dirname "$0")/.."
[ -d dist ] || { echo "no dist/ — run npm run build first" >&2; exit 1; }
SHA=$(git rev-parse --short HEAD)
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
git worktree add -q --detach "$WORK"
cd "$WORK"
git checkout -q --orphan publish-tmp
git rm -rq --cached . 2>/dev/null || true
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
mkdir dist && cp -R "$OLDPWD/dist/." dist/
git add -A
git commit -q -m "site: built from $SHA"
git push -qf origin HEAD:site
cd "$OLDPWD"
git worktree remove --force "$WORK"
echo "published site branch from $SHA"