The local branch survived the worktree and collided on the second run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
22 lines
762 B
Bash
Executable File
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"
|