summaryrefslogtreecommitdiff
path: root/deploy.sh
blob: 5fa8abf65496ca86b919df230162e0e189b04a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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/