summaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh11
1 files 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"