diff options
| author | Void Agent <void@jayrup.hermes> | 2026-07-31 18:52:14 +0100 |
|---|---|---|
| committer | Void Agent <void@jayrup.hermes> | 2026-07-31 18:52:14 +0100 |
| commit | 2885861a92691b8200a9b9a520179d079fbb2c37 (patch) | |
| tree | 8042f7caca1ac657e86bfc6912f528ba197da2ea /deploy.sh | |
| parent | ea040cf5dadf682e8d7cec581a61baaa7302479b (diff) | |
harden deploy: strict mode, mktemp build dirs, pinned quarto digest, no fixed /tmp paths
Diffstat (limited to 'deploy.sh')
| -rwxr-xr-x | deploy.sh | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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/ |
