games_app/deploy/gitea-stack/finalize.sh
Your Name e802ee23d5
Some checks failed
CI / test-and-build (push) Failing after 33s
Harden tloto-deploy and document Gitea CI/CD runbook
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 20:07:47 +02:00

47 lines
1.6 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
echo "== pull app =="
cd ~/games_app
# use tokenized fetch
TOKEN="$(grep -A1 'Push token' ~/gitea-push-credentials.txt | tail -1 | tr -d ' \r')"
git remote set-url origin "http://tloto-admin:${TOKEN}@127.0.0.1:3000/tloto-admin/games_app.git"
git fetch origin main
git reset --hard origin/main
git remote set-url origin "http://127.0.0.1:3000/tloto-admin/games_app.git"
cp -a /tmp/games_app.env.bak .env 2>/dev/null || true
# ensure .env still present
test -f .env
chmod 600 .env
echo "== refresh deploy tool =="
bash deploy/release/install-deploy-tool.sh
echo "== ufw registry =="
sudo ufw allow from 172.16.0.0/12 to any port 5000 proto tcp || true
echo "== tloto-deploy dry path (current HEAD, skip migrate) =="
SHA="$(git rev-parse HEAD)"
/opt/tloto/bin/tloto-deploy --ref "$SHA" --mode http --skip-migrate
echo "== verify manual npm scripts =="
cd ~/games_app
sudo npm run phase-b:status || sudo docker compose ps
curl -fsS http://127.0.0.1:9080/health | head -c 100; echo
curl -fsS http://127.0.0.1:9080/api/v1/setup/status; echo
echo "== actions status =="
sudo -u postgres psql -d gitea -c "SELECT id, title, status, started, stopped FROM action_run ORDER BY id DESC LIMIT 5;"
sudo docker logs tloto_act_runner --tail 30
echo "== cleanup oneshots =="
bash ~/gitea/cleanup-oneshots.sh 2>/dev/null || true
echo "== edge (optional HTTP git.tloto.net host header) =="
cd ~/edge
# copy compose from repo if present
cp -a ~/games_app/deploy/edge/* ~/edge/ 2>/dev/null || true
sudo docker compose --profile edge up -d 2>/dev/null || echo "edge skip/fail non-fatal"
echo "FINALIZE_OK"