diff options
| author | Void Agent <void@jayrup.hermes> | 2026-10-22 23:00:39 +0100 |
|---|---|---|
| committer | Void Agent <void@jayrup.hermes> | 2026-10-22 23:00:39 +0100 |
| commit | b81fa0b2040e5b1b97806ffbf242948e74c4ef88 (patch) | |
| tree | fe024c052dd895bf81cf04a3d864eb0ed386576c | |
| parent | e71d3f17e33ab93e652bfadb7d97d56b1c672c87 (diff) | |
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.
| -rwxr-xr-x | deploy.sh | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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" |
