91d1355721
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.3 KiB
Bash
Executable File
33 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# deploy-site.sh — rsync the built Astro 官网 (web/website/dist/) to the
|
|
# pangolin1 VPS web root (/var/www/pangolin-site). Deploy user is root — the
|
|
# CI deploy key (secrets.DEPLOY_SSH_KEY) is authorized for root on the host.
|
|
# Static files only; nginx/caddy serves them directly, no service restart
|
|
# needed. Assumes it is invoked from the repo root, after compile-site.sh has
|
|
# produced web/website/dist/.
|
|
set -euo pipefail
|
|
|
|
# shellcheck source=scripts/ci/lib-ssh.sh
|
|
. scripts/ci/lib-ssh.sh
|
|
|
|
# setup_ssh registers the EXIT cleanup trap itself (before writing the key),
|
|
# so a mid-setup failure still cleans up — see lib-ssh.sh.
|
|
setup_ssh
|
|
|
|
# Guard against deploying a missing/empty build: `rsync --delete` against an
|
|
# empty source would wipe the live site.
|
|
if [ ! -d web/website/dist ]; then
|
|
echo "==> deploy-site: web/website/dist/ does not exist — refusing to deploy" >&2
|
|
exit 1
|
|
fi
|
|
if ! find web/website/dist -mindepth 1 -print -quit | grep -q .; then
|
|
echo "==> deploy-site: web/website/dist/ is empty — refusing to deploy" >&2
|
|
exit 1
|
|
fi
|
|
|
|
DEPLOY_TARGET="root@${DEPLOY_HOST}:/var/www/pangolin-site/"
|
|
echo "==> deploy-site: rsync web/website/dist/ -> ${DEPLOY_TARGET}"
|
|
rsync -az --delete -e "${RSYNC_SSH}" web/website/dist/ "${DEPLOY_TARGET}"
|
|
|
|
echo "==> deploy-site: done"
|