games_app/deploy/gitea-stack/kick-ci.sh
Your Name 156d37ea26
All checks were successful
CI / test-and-build (push) Successful in 36s
Fix CI runner Docker image and deploy SSH ForceCommand wrapper
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 20:38:57 +02:00

45 lines
1.7 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
NOW="$(date +%s)"
sudo -u postgres psql -d gitea <<SQL
UPDATE action_run_job SET status=5, stopped=${NOW} WHERE status IN (1,2);
UPDATE action_run SET status=5, stopped=${NOW} WHERE status IN (1,2);
SELECT id, status FROM action_run ORDER BY id DESC LIMIT 8;
SELECT id, run_id, status, runner_id FROM action_run_job ORDER BY id DESC LIMIT 8;
SQL
cd ~/gitea
sudo docker compose --profile runner restart runner
sleep 4
# Trigger workflow via API (workflow_dispatch)
set -a; source .env; set +a
# Create empty commit on server copy to trigger push CI
cd ~/games_app
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 checkout main
git pull --ff-only origin main || true
git commit --allow-empty -m "ci: kick runner $(date -u +%H%M%S)"
git push origin main
git remote set-url origin "http://127.0.0.1:3000/tloto-admin/games_app.git"
sleep 8
sudo docker logs tloto_act_runner --tail 40
sudo -u postgres psql -d gitea -c "SELECT id, left(title,40) AS title, status FROM action_run ORDER BY id DESC LIMIT 5;"
# watch up to 3 minutes for a job container
for i in $(seq 1 12); do
echo "watch $i"
sudo docker ps -a --format '{{.Names}} {{.Image}} {{.Status}}' | grep -vE 'tloto_|crypto_|prediqo_|REGISTRY' || true
sudo docker ps -a --format '{{.Names}} {{.Image}} {{.Status}}' | head -40
st="$(sudo -u postgres psql -d gitea -tAc 'SELECT status FROM action_run ORDER BY id DESC LIMIT 1' | tr -d '[:space:]')"
echo "status=$st"
sudo docker logs tloto_act_runner --tail 8
if [[ "$st" == "3" || "$st" == "4" ]]; then
break
fi
sleep 15
done
echo KICK_DONE