garden/scripts/auto-rebuild.sh
Vigilio Desto 5703e606d0
garden: port content, rebuild public/, add new scripts and features
- Ported Ludo profile from vault to garden
- Added auto-rebuild watcher scripts
- Updated static data snapshots
- Added garden-features.js and api-garden.json
- Added GARDEN-CONTENT-GAPS.md for tracking
- Rebuilt Hugo public/ output
2026-06-08 02:11:24 +02:00

52 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# auto-rebuild.sh — Auto-rebuild garden: fetch API data → hugo → checkpoint
#
# Called by auto-rebuild-watcher.sh when content/ changes.
# Also callable manually: bash scripts/auto-rebuild.sh
set -euo pipefail
DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$DIR"
echo "=== Garden auto-rebuild: $(date -u +%Y-%m-%dT%H:%M:%SZ) ==="
# 1. Fetch Estate API snapshots
echo ""
bash scripts/prebuild-fetch.sh || echo "⚠️ prebuild-fetch.sh failed, continuing..."
# 2. Build Hugo site
echo ""
echo "→ Running hugo..."
hugo 2>&1
HUGO_EXIT=$?
if [ $HUGO_EXIT -ne 0 ]; then
echo "✗ Hugo build failed (exit $HUGO_EXIT)"
# Still write checkpoint so next agent knows state
fi
# 3. Gather stats for checkpoint
PUBLISHED_COUNT=$(find content/ -name '*.md' -not -path '*/_index.md' -not -name '_index.md' | wc -l)
PUBLIC_PAGE_COUNT=$(find public/ -name '*.html' | wc -l)
NEXT_ACTION="check garden estate dashboard health at next patrol"
# 4. Write checkpoint
CHECKPOINT="$DIR/.garden_checkpoint"
cat > "$CHECKPOINT" <<EOF
# Garden Checkpoint
# Auto-generated by auto-rebuild.sh — do not edit manually
last_build: $(date -u +%Y-%m-%dT%H:%M:%SZ)
last_api_sync: $(date -u +%Y-%m-%dT%H:%M:%SZ)
published_pages: $PUBLISHED_COUNT
public_html_files: $PUBLIC_PAGE_COUNT
hugo_exit_code: $HUGO_EXIT
next_action: $NEXT_ACTION
EOF
echo ""
echo "✓ Garden rebuilt at $(date -u)"
echo " Content pages: $PUBLISHED_COUNT"
echo " Public HTML: $PUBLIC_PAGE_COUNT"
echo " Hugo exit: $HUGO_EXIT"
echo " Checkpoint: $CHECKPOINT"