From b81fa0b2040e5b1b97806ffbf242948e74c4ef88 Mon Sep 17 00:00:00 2001 From: Void Agent Date: Thu, 22 Oct 2026 23:00:39 +0100 Subject: deploy: fix build-dir git calls, capture SHA, drop dead mkdir deploy.sh cd'd into the mktemp build dir before calling git, so `git archive HEAD` failed with 'not a git repository' and the whole deploy aborted. Resolve REPO from the script location and pass -C to every git call, and write the archive to an absolute path since -C also makes --output relative to the repo. The deploy marker also ran `git rev-parse` from the temp dir; because it sat inside a command substitution, set -e did not catch it and last-deploy.txt silently recorded an empty commit. Capture SHA up front. Also drop `mkdir -p public/cv`, left over from when the CV was copied into a directory that nothing reads. --- deploy.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/deploy.sh b/deploy.sh index 9daf85b..51159fe 100755 --- a/deploy.sh +++ b/deploy.sh @@ -6,11 +6,17 @@ # Strict mode: a failed render exits BEFORE rsync --delete can touch the VPS. set -euo pipefail +# Resolve the repo root from this script's location and capture the SHA up +# front: the build runs inside a temp dir with no .git, so every later git +# call must be pointed at $REPO explicitly. +REPO="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +SHA="$(git -C "$REPO" rev-parse --short HEAD)" + # 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 +git -C "$REPO" archive --format=tar --output="$BUILD_DIR/tree.tar" HEAD tar xf tree.tar rm tree.tar @@ -31,7 +37,6 @@ find . -name "*.qmd" -not -path "./.*" -not -path "./public/*" | while read -r f done # 4. Add cv -mkdir -p public/cv cp cv/index.pdf public/cv.pdf cp cv/index.txt public/cv.txt @@ -45,7 +50,7 @@ cp -r assets/* public/assets/ cp assets/public_key public/public_key.txt # 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 +printf 'deployed %s commit %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$SHA" > public/last-deploy.txt echo "Pushing to vps" -- cgit v1.2.3