Fix CI runner Docker image and deploy SSH ForceCommand wrapper
All checks were successful
CI / test-and-build (push) Successful in 36s
All checks were successful
CI / test-and-build (push) Successful in 36s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
293d628977
commit
156d37ea26
@ -14,7 +14,7 @@ GITEA_INTERNAL_TOKEN=change-me-internal-token
|
|||||||
# Filled by register-runner.sh after first admin bootstrap
|
# Filled by register-runner.sh after first admin bootstrap
|
||||||
GITEA_RUNNER_REGISTRATION_TOKEN=
|
GITEA_RUNNER_REGISTRATION_TOKEN=
|
||||||
GITEA_RUNNER_NAME=tloto-vps-runner
|
GITEA_RUNNER_NAME=tloto-vps-runner
|
||||||
GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm
|
GITEA_RUNNER_LABELS=ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-22.04,ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-22.04
|
||||||
|
|
||||||
# Admin account created by bootstrap-gitea-admin.sh
|
# Admin account created by bootstrap-gitea-admin.sh
|
||||||
GITEA_ADMIN_USER=tloto-admin
|
GITEA_ADMIN_USER=tloto-admin
|
||||||
|
|||||||
@ -93,7 +93,8 @@ services:
|
|||||||
GITEA_INSTANCE_URL: http://gitea:3000
|
GITEA_INSTANCE_URL: http://gitea:3000
|
||||||
GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_REGISTRATION_TOKEN:-}
|
GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_REGISTRATION_TOKEN:-}
|
||||||
GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-tloto-vps-runner}
|
GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-tloto-vps-runner}
|
||||||
GITEA_RUNNER_LABELS: ${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm}
|
# act-* images include docker CLI so jobs can build/push via mounted docker.sock
|
||||||
|
GITEA_RUNNER_LABELS: ${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-22.04,ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-22.04}
|
||||||
volumes:
|
volumes:
|
||||||
- ./runner/config.yaml:/config.yaml:ro
|
- ./runner/config.yaml:/config.yaml:ro
|
||||||
- runner-data:/data
|
- runner-data:/data
|
||||||
|
|||||||
12
deploy/gitea-stack/fix-wrapper-and-ci-status.sh
Normal file
12
deploy/gitea-stack/fix-wrapper-and-ci-status.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
bash ~/games_app/deploy/release/install-deploy-tool.sh
|
||||||
|
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -i ~/gitea-deploy-ssh/id_ed25519 deploy@127.0.0.1 \
|
||||||
|
'/opt/tloto/bin/tloto-deploy --help' | head -25
|
||||||
|
sudo -u postgres psql -d gitea <<'SQL'
|
||||||
|
UPDATE action_run_job SET status=3, stopped=EXTRACT(EPOCH FROM NOW())::bigint WHERE id=7 AND status IN (1,2,6);
|
||||||
|
UPDATE action_run SET status=3, stopped=EXTRACT(EPOCH FROM NOW())::bigint WHERE id=7 AND status IN (1,2,6);
|
||||||
|
SELECT id, status FROM action_run_job WHERE id=7;
|
||||||
|
SELECT id, status FROM action_run WHERE id=7;
|
||||||
|
SQL
|
||||||
|
echo WRAPPER_OK
|
||||||
44
deploy/gitea-stack/kick-ci.sh
Normal file
44
deploy/gitea-stack/kick-ci.sh
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#!/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
|
||||||
16
deploy/gitea-stack/poll-ci-short.sh
Normal file
16
deploy/gitea-stack/poll-ci-short.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
sudo docker logs tloto_act_runner --tail 20
|
||||||
|
sudo -u postgres psql -d gitea -c "SELECT id, left(title,40) AS title, status FROM action_run ORDER BY id DESC LIMIT 6;"
|
||||||
|
for i in 1 2 3 4 5 6; do
|
||||||
|
echo "--- wait $i ---"
|
||||||
|
sleep 15
|
||||||
|
sudo docker ps -a --format '{{.Names}} {{.Image}} {{.Status}}' | head -35
|
||||||
|
sudo docker logs tloto_act_runner --tail 10
|
||||||
|
st="$(sudo -u postgres psql -d gitea -tAc 'SELECT status FROM action_run ORDER BY id DESC LIMIT 1' | tr -d '[:space:]')"
|
||||||
|
echo "latest_status=$st"
|
||||||
|
if [[ "$st" == "3" || "$st" == "4" || "$st" == "5" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
sudo -u postgres psql -d gitea -c "SELECT id, left(title,40) AS title, status FROM action_run ORDER BY id DESC LIMIT 6;"
|
||||||
@ -1,7 +1,7 @@
|
|||||||
# act_runner config — runner has docker.sock for CI builds only.
|
# act_runner config — runner has docker.sock for CI builds only.
|
||||||
# It must NOT execute production deploy; that goes through tloto-deploy via SSH ForceCommand / sudoers.
|
# It must NOT execute production deploy; that goes through tloto-deploy via SSH ForceCommand / sudoers.
|
||||||
log:
|
log:
|
||||||
level: info
|
level: debug
|
||||||
|
|
||||||
runner:
|
runner:
|
||||||
capacity: 1
|
capacity: 1
|
||||||
|
|||||||
14
deploy/gitea-stack/update-runner-labels.sh
Normal file
14
deploy/gitea-stack/update-runner-labels.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
cd ~/gitea
|
||||||
|
LABELS='ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-22.04,ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-22.04'
|
||||||
|
if grep -q '^GITEA_RUNNER_LABELS=' .env; then
|
||||||
|
sed -i "s|^GITEA_RUNNER_LABELS=.*|GITEA_RUNNER_LABELS=${LABELS}|" .env
|
||||||
|
else
|
||||||
|
echo "GITEA_RUNNER_LABELS=${LABELS}" >> .env
|
||||||
|
fi
|
||||||
|
# Pre-pull job image
|
||||||
|
sudo docker pull ghcr.io/catthehacker/ubuntu:act-22.04
|
||||||
|
# Re-register so labels refresh cleanly
|
||||||
|
bash ./register-runner.sh
|
||||||
|
echo LABELS_OK
|
||||||
20
deploy/gitea-stack/verify-final.sh
Normal file
20
deploy/gitea-stack/verify-final.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
echo "== stacks =="
|
||||||
|
sudo docker ps --format '{{.Names}} {{.Status}}' | sort
|
||||||
|
echo "== health =="
|
||||||
|
curl -fsS http://127.0.0.1:9080/health | head -c 120; echo
|
||||||
|
curl -fsS http://127.0.0.1:3000/api/v1/version; echo
|
||||||
|
curl -fsS http://127.0.0.1:5000/v2/; echo
|
||||||
|
echo "== actions jobs =="
|
||||||
|
sudo -u postgres psql -d gitea -c "SELECT id, run_id, status FROM action_run_job ORDER BY id DESC LIMIT 8;"
|
||||||
|
echo "== release =="
|
||||||
|
cat /var/lib/tloto/current.json
|
||||||
|
echo
|
||||||
|
echo "== npm scripts =="
|
||||||
|
cd ~/games_app
|
||||||
|
sudo npm run phase-b:status | head -20
|
||||||
|
echo "== ssh forcecommand smoke =="
|
||||||
|
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -i ~/gitea-deploy-ssh/id_ed25519 deploy@127.0.0.1 \
|
||||||
|
"/opt/tloto/bin/tloto-deploy --help" | head -20
|
||||||
|
echo VERIFY_OK
|
||||||
@ -38,13 +38,15 @@ if [[ -z "$cmd" ]]; then
|
|||||||
echo "tloto-deploy-ssh-wrapper: missing SSH_ORIGINAL_COMMAND" >&2
|
echo "tloto-deploy-ssh-wrapper: missing SSH_ORIGINAL_COMMAND" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Must start with absolute path to tloto-deploy
|
case "$cmd" in
|
||||||
if [[ ! "$cmd" =~ ^/opt/tloto/bin/tloto-deploy([[:space:]]|$) ]]; then
|
/opt/tloto/bin/tloto-deploy|/opt/tloto/bin/tloto-deploy\ *) ;;
|
||||||
|
*)
|
||||||
echo "refusing command: $cmd" >&2
|
echo "refusing command: $cmd" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
;;
|
||||||
# Disallow shell metacharacters
|
esac
|
||||||
if [[ "$cmd" =~ [\;\&\|\<\>\`\$\(\)] ]]; then
|
# Disallow shell metacharacters via tr/grep (avoid fragile [[ =~ ]] classes)
|
||||||
|
if printf '%s' "$cmd" | grep -Eq '[;&|<>`$()]' ; then
|
||||||
echo "refusing unsafe characters" >&2
|
echo "refusing unsafe characters" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -38,11 +38,13 @@ tloto-deploy --rollback
|
|||||||
|
|
||||||
Push/PR sur `main` / `master` / `develop` → workflow **CI** :
|
Push/PR sur `main` / `master` / `develop` → workflow **CI** :
|
||||||
|
|
||||||
1. `npm ci` + compile backend
|
1. Checkout git + `npm ci` + compile backend
|
||||||
2. Build images Docker
|
2. Build images Docker (job image `ghcr.io/catthehacker/ubuntu:act-22.04` avec CLI Docker)
|
||||||
3. Push vers registry local `127.0.0.1:5000/tloto-*:<sha12>`
|
3. Push vers registry local `172.16.0.1:5000/tloto-*:<sha12>`
|
||||||
4. **Pas** de mise en prod
|
4. **Pas** de mise en prod
|
||||||
|
|
||||||
|
Le runner est déclaré avec les labels `ubuntu-latest` / `ubuntu-22.04`. Les secrets Actions `DEPLOY_SSH_KEY` et `DEPLOY_SSH_HOST` servent uniquement au workflow **Deploy** manuel.
|
||||||
|
|
||||||
## pgAdmin (Windows)
|
## pgAdmin (Windows)
|
||||||
|
|
||||||
Voir `~/pgadmin-db-credentials.txt` sur le VPS. Tunnel SSH uniquement — jamais exposer 5432.
|
Voir `~/pgadmin-db-credentials.txt` sur le VPS. Tunnel SSH uniquement — jamais exposer 5432.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user