Build / Desktop, server and tools (push) Successful in 29s
rsync -a carried the staging folder's mode to /var/www/meweb.arasaka.software, and the meweb user could no longer enter it (status=200/CHDIR). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
43 lines
1.1 KiB
Bash
Executable File
43 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
archive=$1
|
|
app=/var/www/meweb.arasaka.software
|
|
backups=/var/backups/meweb.arasaka.software
|
|
health=http://127.0.0.1:5480/api/info
|
|
stamp=$(date -u +%Y%m%d%H%M%S)
|
|
stage=$(mktemp -d)
|
|
chmod 755 "$stage"
|
|
trap 'rm -rf "$stage"' EXIT
|
|
|
|
tar -xzf "$archive" -C "$stage"
|
|
test -x "$stage/MeWeb.Server"
|
|
|
|
snapshot=""
|
|
if [ -x "$app/MeWeb.Server" ]; then
|
|
snapshot="$backups/meweb-$stamp"
|
|
rsync -a "$app/" "$snapshot/"
|
|
ls -1dt "$backups"/meweb-* 2>/dev/null | tail -n +4 | xargs -r rm -rf
|
|
fi
|
|
|
|
sudo systemctl stop meweb || true
|
|
rsync -a --delete "$stage/" "$app/"
|
|
sudo systemctl start meweb
|
|
|
|
for attempt in $(seq 1 30); do
|
|
if curl -fsS "$health" | grep -q "\"commit\":\"$COMMIT\""; then
|
|
echo "deployed $COMMIT: $(curl -fsS "$health")"
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "::error::the new server did not answer with commit $COMMIT"
|
|
sudo systemctl status meweb --no-pager | tail -20 || true
|
|
if [ -n "$snapshot" ]; then
|
|
sudo systemctl stop meweb || true
|
|
rsync -a --delete "$snapshot/" "$app/"
|
|
sudo systemctl start meweb
|
|
echo "rolled back to $snapshot"
|
|
fi
|
|
exit 1
|