kotsukotsu/scripts/deploy-app.sh
polwex 78cc1b95bb
Some checks failed
ci/woodpecker/push/job Pipeline failed
surrender
2026-04-19 08:51:24 +07:00

28 lines
806 B
Bash

#!/usr/bin/env bash
set -euo pipefail
target_host="${1:-root@sortug.com}"
service_name="${SERVICE_NAME:-kotsukotsu}"
current_path="${CURRENT_PATH:-/var/lib/kotsukotsu/current}"
health_url="${HEALTH_URL:-http://127.0.0.1:5174/healthz}"
store_path="$(nix build --accept-flake-config --print-out-paths .#default | tail -n 1)"
echo "Built ${store_path}"
echo "Copying package to ${target_host}"
nix copy --to "ssh://${target_host}" "${store_path}"
echo "Activating release on ${target_host}"
ssh "${target_host}" "
set -euo pipefail
ln -sfn '${store_path}' '${current_path}'
systemctl restart '${service_name}'
for _ in 1 2 3 4 5 6 7 8 9 10; do
if curl -fsS '${health_url}' >/dev/null; then
exit 0
fi
sleep 1
done
echo 'health check failed for ${service_name}' >&2
exit 1
"