From 86d4fbf81c5bb757c7652083e1a6f4c6fed63770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Geel=20Weirs=C3=B8e?= Date: Thu, 11 Jun 2026 19:19:08 +0200 Subject: [PATCH] ci: deploy via tar over SSH with atomic swap (runner has no rsync) Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitea/workflows/deploy.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index d370c1e..8412536 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -32,6 +32,9 @@ jobs: - name: Build site run: npm run build + # tar over SSH (the runner image has no rsync). Build is unpacked into + # a .new dir on CT148 and atomically swapped in, so the live web root is + # never left half-written. - name: Deploy dist/ to CT148 over SSH env: DEPLOY_HOST: 192.168.10.148 @@ -42,7 +45,12 @@ jobs: mkdir -p ~/.ssh echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key + SSH="ssh -i $HOME/.ssh/deploy_key -o StrictHostKeyChecking=accept-new" ssh-keyscan -t ed25519 "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null || true - rsync -az --delete \ - -e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=accept-new" \ - dist/ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/" + $SSH "$DEPLOY_USER@$DEPLOY_HOST" "rm -rf $DEPLOY_PATH.new && mkdir -p $DEPLOY_PATH.new" + tar -C dist -czf - . | $SSH "$DEPLOY_USER@$DEPLOY_HOST" \ + "tar -C $DEPLOY_PATH.new -xzf - \ + && rm -rf $DEPLOY_PATH.old \ + && { mv $DEPLOY_PATH $DEPLOY_PATH.old 2>/dev/null || true; } \ + && mv $DEPLOY_PATH.new $DEPLOY_PATH \ + && rm -rf $DEPLOY_PATH.old"