Files
garden-astro/deploy/auto-build.sh
T
wesandClaude Fable 5 3d70e23471 Manual rebuild hook + polish: single title h1, '›' tree marker
- deploy/rebuild-hook.py: tiny stdlib HTTP service (:18101) — button
  page for the Homepage dashboard iframe, POST /rebuild runs
  auto-build.sh --force, /status + /healthz for feedback/monitoring
- auto-build.sh: --force flag + flock so timer and manual builds
  serialize
- [...slug].astro: skip the synthetic h1 when the note body already
  opens with an identical h1

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 21:45:36 -04:00

39 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# Timer target: rebuild the garden only when the vault or repo changed.
# Successor to the Quartz update_quartz_docker.sh change-detection loop.
# Usage: auto-build.sh [--force] (--force skips change detection — used
# by the manual rebuild hook)
set -eu
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
VAULT="${VAULT:-/home/nox/docker/obsidian/vaults/weeslahw_coppermind}"
STATE="$REPO/.build_state"
FORCE=0
[ "${1:-}" = "--force" ] && FORCE=1
cd "$REPO"
# serialize builds: the 5-min timer and the manual hook must never run
# docker/npm into the same checkout concurrently
exec 9>"$REPO/.build.lock"
flock 9
# a dirty tree can make pull fail; still rebuild whatever is checked out
git pull -q || echo "git pull failed (dirty tree?) — building local state"
# signature covers committed HEAD, any uncommitted repo edits, and vault mtimes
sig=$({
git rev-parse HEAD
git status --porcelain=v1
git diff
find "$VAULT" -name .obsidian -prune -o -type f -printf '%T@ %p\n' | sort
} | sha256sum | cut -d' ' -f1)
if [ "$FORCE" -eq 0 ] && [ -f "$STATE" ] && [ "$(cat "$STATE")" = "$sig" ]; then
exit 0
fi
sh "$REPO/deploy/build.sh"
printf %s "$sig" >"$STATE"
echo "garden rebuilt $(date -Is)"