#!/usr/bin/env bash # deploy.sh — local native-quarto build + deploy for jayrup.me. # For machines with quarto installed natively (e.g. Arch laptop / voidlaptop). # The Docker-based path is deploy-docker.sh (used by meru's post-receive hook). # # Strict mode: a failed render exits BEFORE rsync --delete can touch the VPS. set -euo pipefail # 1. Render into a fresh temp dir so a partial build never gets deployed BUILD_DIR="$(mktemp -d /tmp/homepage-local.XXXXXX)" trap 'rm -rf "$BUILD_DIR"' EXIT cd "$BUILD_DIR" git archive --format=tar --output=tree.tar HEAD tar xf tree.tar rm tree.tar # 2. Render the whole website (HTML) # This creates the directories and index.html files correctly quarto render --to html # 3. Render the Plain Text versions manually to ensure mirroring # We find every .qmd, and render it to a .txt in the corresponding public/ folder find . -name "*.qmd" -not -path "./.*" -not -path "./public/*" | while read -r file; do # Get the directory structure (e.g., ./projects/index.qmd -> projects) rel_dir=$(dirname "${file#./}") # Get the filename without extension (e.g., index) base_name=$(basename "$file" .qmd) # Render to plain text directly into the correct public sub-directory quarto render "$file" --to plain --output "${base_name}.txt" --output-dir "public/$rel_dir" done # 4. Add cv mkdir -p public/cv cp cv/index.pdf public/cv.pdf cp cv/index.txt public/cv.txt # 5. Add assets (static files bundled in the repo) cp assets/dissertation.pdf public/dissertation.pdf cp assets/public_key public/public_key # 6. Deploy marker printf 'deployed %s commit %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$(git rev-parse --short HEAD)" > public/last-deploy.txt echo "Pushing to vps" # Only reached if all renders succeeded (set -e) rsync -avz --delete public/ jayrup.me:~/homepage/public/