summaryrefslogtreecommitdiff
path: root/publish.sh
diff options
context:
space:
mode:
authorlsof <lsof@mailbox.org>2026-04-29 23:06:05 +0200
committerlsof <lsof@mailbox.org>2026-04-29 23:06:09 +0200
commit38b9943f0437ec2f62fc7ac0247ccdf9f4dc01a0 (patch)
tree44166062756a17268637817f0a761914fd3185b7 /publish.sh
parent315a8e380550c88cfeb6fc6af633d12baf16ed82 (diff)
update publish.sh
moved off codeberg pages now own VPS
Diffstat (limited to 'publish.sh')
-rwxr-xr-xpublish.sh51
1 files changed, 33 insertions, 18 deletions
diff --git a/publish.sh b/publish.sh
index 2294af1..22dde09 100755
--- a/publish.sh
+++ b/publish.sh
@@ -1,22 +1,37 @@
-#!/bin/sh
+#!/bin/bash
-set -eox pipefail
+set -eo pipefail
-base="$(realpath $(dirname "$0"))"
-git checkout main
-hash="$(git rev-parse HEAD| head -c 12)"
-temp="/tmp/site-$hash"
+cd "$(dirname "$0")"
+
+VPS_HOST="${VPS_HOST:-}"
+VPS_USER="${VPS_USER:-root}"
+remote_target="/var/www/html"
+tarball_name="site.tar.gz"
+
+die() {
+ echo -e ERR "$*" >&2
+ exit 1
+}
+
+if [ -z "$VPS_HOST" ] || [ -z "$VPS_USER" ]; then
+ echo VPS_HOST? VPS_USER?
+ exit 1
+fi
+
+set -x
-git push
zola build
-cd /tmp
-git clone --branch pages "$base" "$temp"
-cd "$temp"
-git rm -r "*" || :
-cp -ar "$base"/public/* "$base"/public/.* "$base"/.domains .
-git add --all
-git commit -m "Publish $hash" || :
-git remote add cb 'ssh://git@codeberg.org/lsof/pages.git'
-git push cb
-cd
-rm -rf "$temp"
+tar -czf "$tarball_name" -C public/ .
+scp "$tarball_name" "$VPS_USER@$VPS_HOST:$REMOTE_TMP/$tarball_name"
+
+ssh "$VPS_USER@$VPS_HOST" <<EOF
+ set -ex # stop on any error
+ sudo mkdir -p "$remote_target"
+ sudo rm -rf "$remote_target"/*
+ sudo tar -xzf "$REMOTE_TMP/$tarball_name" -C "$remote_target"
+ sudo rm "$REMOTE_TMP/$tarball_name"
+ echo "Unpacking completed."
+EOF
+
+rm -f "$tarball_name"