diff --git a/deploy/gitea-stack/.env.example b/deploy/gitea-stack/.env.example index a70609d5..ea12b714 100644 --- a/deploy/gitea-stack/.env.example +++ b/deploy/gitea-stack/.env.example @@ -14,7 +14,7 @@ GITEA_INTERNAL_TOKEN=change-me-internal-token # Filled by register-runner.sh after first admin bootstrap GITEA_RUNNER_REGISTRATION_TOKEN= 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 GITEA_ADMIN_USER=tloto-admin diff --git a/deploy/gitea-stack/docker-compose.yml b/deploy/gitea-stack/docker-compose.yml index 9a47f665..b21033c6 100644 --- a/deploy/gitea-stack/docker-compose.yml +++ b/deploy/gitea-stack/docker-compose.yml @@ -93,7 +93,8 @@ services: GITEA_INSTANCE_URL: http://gitea:3000 GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_REGISTRATION_TOKEN:-} 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: - ./runner/config.yaml:/config.yaml:ro - runner-data:/data diff --git a/deploy/gitea-stack/fix-wrapper-and-ci-status.sh b/deploy/gitea-stack/fix-wrapper-and-ci-status.sh new file mode 100644 index 00000000..d6662456 --- /dev/null +++ b/deploy/gitea-stack/fix-wrapper-and-ci-status.sh @@ -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 diff --git a/deploy/gitea-stack/kick-ci.sh b/deploy/gitea-stack/kick-ci.sh new file mode 100644 index 00000000..067c6bbd --- /dev/null +++ b/deploy/gitea-stack/kick-ci.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -euo pipefail +NOW="$(date +%s)" +sudo -u postgres psql -d gitea <&2 exit 1 fi -# Must start with absolute path to tloto-deploy -if [[ ! "$cmd" =~ ^/opt/tloto/bin/tloto-deploy([[:space:]]|$) ]]; then - echo "refusing command: $cmd" >&2 - exit 1 -fi -# Disallow shell metacharacters -if [[ "$cmd" =~ [\;\&\|\<\>\`\$\(\)] ]]; then +case "$cmd" in + /opt/tloto/bin/tloto-deploy|/opt/tloto/bin/tloto-deploy\ *) ;; + *) + echo "refusing command: $cmd" >&2 + exit 1 + ;; +esac +# Disallow shell metacharacters via tr/grep (avoid fragile [[ =~ ]] classes) +if printf '%s' "$cmd" | grep -Eq '[;&|<>`$()]' ; then echo "refusing unsafe characters" >&2 exit 1 fi diff --git a/docs/GITEA-CICD.md b/docs/GITEA-CICD.md index cdba7450..1df291e8 100644 --- a/docs/GITEA-CICD.md +++ b/docs/GITEA-CICD.md @@ -38,11 +38,13 @@ tloto-deploy --rollback Push/PR sur `main` / `master` / `develop` → workflow **CI** : -1. `npm ci` + compile backend -2. Build images Docker -3. Push vers registry local `127.0.0.1:5000/tloto-*:` +1. Checkout git + `npm ci` + compile backend +2. Build images Docker (job image `ghcr.io/catthehacker/ubuntu:act-22.04` avec CLI Docker) +3. Push vers registry local `172.16.0.1:5000/tloto-*:` 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) Voir `~/pgadmin-db-credentials.txt` sur le VPS. Tunnel SSH uniquement — jamais exposer 5432.