gethumanai-landing/deploy.sh

71 lines
2.2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
# Host: SATURN
# Run this script from SATURN to commit, push, deploy, and smoke-test.
VPS="ubuntu-4gb-hel1-1"
REPO_DIR="/home/oskar/projects/gethumanai-landing"
FORGEJO_REMOTE="ssh://git@100.108.208.3:222/oskar/gethumanai-landing.git"
# ── 1. Commit & push (SATURN) ──────────────────────────────────────────────
# Host: SATURN
cd "$REPO_DIR"
if [ -n "$(git status --porcelain)" ]; then
git add -A
git commit -m "chore: deploy $(date '+%Y-%m-%d %H:%M')"
fi
git push origin main
# ── 2. Pull, rebuild, smoke-test on VPS ───────────────────────────────────
# Host: ubuntu-4gb-hel1-1
ssh "$VPS" bash -s <<'REMOTE'
set -euo pipefail
DEPLOY_DIR="/home/oskar/gethumanai-landing"
if [ ! -d "$DEPLOY_DIR/.git" ]; then
git clone ssh://git@100.108.208.3:222/oskar/gethumanai-landing.git "$DEPLOY_DIR"
fi
cd "$DEPLOY_DIR"
git pull origin main
docker compose up -d --build --remove-orphans
# ── 3. Smoke test ─────────────────────────────────────────────────────────
# Host: ubuntu-4gb-hel1-1
echo "Waiting for container to be ready..."
sleep 2
CONTAINER_IP=$(docker inspect humanai-landing \
--format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
smoke_check() {
local path="$1"
local expect="$2"
local url="http://${CONTAINER_IP}${path}"
local body
body=$(curl -sf --max-time 5 "$url") || {
echo "FAIL GET ${path} — no response (curl exit $?)"
return 1
}
if echo "$body" | grep -qF "$expect"; then
echo "OK GET ${path} — found: ${expect}"
else
echo "FAIL GET ${path} — '${expect}' not in response"
return 1
fi
}
smoke_check "/" "Ludzka strona AI"
smoke_check "/en/" "The human side of AI"
smoke_check "/" "hreflang"
smoke_check "/" "mailto:oskar@gethumanai.com"
smoke_check "/en/" "human review"
echo "Smoke tests passed. Deploy complete."
REMOTE
echo "Done — humanAI landing is live."