Files
blog/scripts/deploy.sh
Gabriel Vidal e97299f282 chore: add a repeatable zipgo deploy + fix the one-build-stale search index
There was no deploy path in the repo at all — the site is served by zipgo on
raspy2, but that was done by hand, so `search-project -u blog.dev.gabvdl.xyz`
found nothing and each deploy was ad-hoc. Add `scripts/deploy.sh` (zipgo deploy
CLI, same shape as the other projects), an `npm run deploy`, and the
`zipgo.deploy` host→folder map. Deliberately no og-screenshot step: the site
ships a curated public/og-image.png that a screenshot would only degrade.

Also fix a real bug this surfaced. `prepare-index.js` runs as `postbuild`, i.e.
AFTER astro copies public/ into dist/, so it only ever updated public/ — and
dist/search-index.json (the one that actually ships) held the PREVIOUS build's
index. Every deploy shipped a search index one post behind. It now mirrors the
index into dist/ as well, tolerating a missing dist/ for a bare postbuild run.

Document the deploy and the Gitea/GitHub remote split in the README.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 12:59:18 +02:00

37 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Deploy the built blog to zipgo on raspy2 (internet HTTPS).
#
# Uses the `zipgo deploy` CLI: it maps the host to its folder and creates the
# domain/subdomain tree on the remote (zipgo's trailing-dot convention):
# -d blog.dev.gabvdl.xyz
# -> domains/gabvdl.xyz/dev./blog. -> https://blog.dev.gabvdl.xyz
#
# Run `npm run build` first, or `npm run deploy`, which builds then runs this.
#
# NOTE: no og:image step. The site ships a curated `public/og-image.png` (wired
# into BaseHead.astro); a screenshot of the index would be strictly worse, so
# unlike the scaffolded project deploys this one deliberately skips
# `og-screenshot`.
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
HOST="blog.dev.gabvdl.xyz"
URL="https://$HOST"
SSH_DEST="gabrielvidal@100.74.118.12:/home/gabrielvidal/services/domains"
if [ ! -d "$PROJECT_DIR/dist" ]; then
echo "error: $PROJECT_DIR/dist not found — run 'npm run build' first." >&2
exit 1
fi
# `astro build`'s postbuild writes the Lunr index into public/, which only lands
# in dist/ on the *next* build. Guard against shipping a stale search index.
if [ ! -s "$PROJECT_DIR/dist/search-index.json" ]; then
echo "error: dist/search-index.json missing — run 'npm run build' again." >&2
exit 1
fi
zipgo deploy "$PROJECT_DIR/dist/" -d "$HOST" --ssh "$SSH_DEST"
echo ""
echo " Deployed URL : $URL (via raspy2, Let's Encrypt HTTPS)"