From 2885861a92691b8200a9b9a520179d079fbb2c37 Mon Sep 17 00:00:00 2001 From: Void Agent Date: Fri, 31 Jul 2026 18:52:14 +0100 Subject: harden deploy: strict mode, mktemp build dirs, pinned quarto digest, no fixed /tmp paths --- deploy.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'deploy.sh') diff --git a/deploy.sh b/deploy.sh index 67402ff..5fa8abf 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,7 +1,18 @@ #!/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. Clear the old garbage -rm -rf public/ +# 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 @@ -14,7 +25,7 @@ find . -name "*.qmd" -not -path "./.*" -not -path "./public/*" | while read -r f 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 @@ -28,6 +39,10 @@ cp cv/index.txt public/cv.txt 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/ -- cgit v1.2.3