Something went wrong. Try again.
A video game where you play as a misaligned AI, deceiving and building power. An experiment in spec-driven development. cameron.tngl.io/misaligned
Something went wrong. Try again.
1.4 kB · 28 lines
Shell
at main
1234567891011121314151617181920212223242526272829#!/usr/bin/env bash# Build the game and publish it to the orphan `pages` branch (Tangled Sites serves# it at https://cameron.tngl.io/misaligned/). Then check the public page shows# this revision. The edge can lag a few minutes; set DEPLOY_ATTEMPTS to wait longer.set -euo pipefailROOT="$(cd "$(dirname "$0")/.." && pwd)"cd "$ROOT"[ -z "$(git status --porcelain --untracked-files=no)" ] || { echo "deploy: commit your changes first" >&2; exit 1; }REV="$(git rev-parse HEAD)"URL="${DEPLOY_URL:-https://cameron.tngl.io/misaligned/}"
npm run ci # type-check, test, build# stamp the revision so we can tell when the public copy is currentsed -i.bak "s|<head>|<head><meta name=\"misaligned-revision\" content=\"$REV\">|" dist/index.html && rm dist/index.html.bak
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXITcp -a dist/. "$TMP"/git -C "$TMP" init -q -b pagesgit -C "$TMP" add -Agit -C "$TMP" -c user.name="$(git config user.name)" -c user.email="$(git config user.email)" commit -q -m "Publish game from ${REV:0:12}"git -C "$TMP" push -q --force "$(git remote get-url origin)" pages:pagesecho "deploy: pushed ${REV:0:12} to pages"
for i in $(seq 1 "${DEPLOY_ATTEMPTS:-12}"); do if curl -fsSL --max-time 20 "$URL" | grep -q "$REV"; then echo "deploy: live at $URL"; exit 0; fi echo "deploy: waiting for the public site ($i)"; sleep 20doneecho "deploy: pushed, but $URL does not show $REV yet" >&2; exit 1