ci: run tests and audit on every push, deploy exact commit with health check
All checks were successful
Deploy Gameservers Control / check (push) Successful in 6s
Deploy Gameservers Control / deploy (push) Has been skipped

- npm audit fix (multer 2.5.0, body-parser, qs, proxy-addr): 0 vulnerabilities
- engines node >=22.9 and .nvmrc (prod runs Node 26)
- GET /healthz for deployment checks
- workflow: check job (npm ci, npm test, npm audit) on every push; deploy only
  on main after checks, with pinned host key, BatchMode and exact commit SHA
- ops/deploy-gameservers-control.sh: lock, refuse dirty tree, fast-forward to
  the commit, npm ci --omit=dev, wait for /healthz, roll back on failure
- stop tracking storage/servers.json (prod storage now lives outside the repo)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-12-02 12:24:15 +01:00
parent 655cf655da
commit 0a7bfc183d
10 changed files with 249 additions and 129 deletions

41
ops/README.md Normal file
View file

@ -0,0 +1,41 @@
# Exploitation
## Déploiement
La CI se connecte en SSH à la VM webapps (`shinuwa@192.168.0.100:2911`) avec la clé
`forgejo-runner@webapps`, puis lance :
```
sudo /usr/local/bin/deploy-gameservers-control --commit '<sha>'
```
Côté serveur, cette clé est limitée par `/usr/local/sbin/deploy-ssh-gate` (commande forcée dans
`~/.ssh/authorized_keys`) : toute nouvelle commande SSH dans le workflow doit y être ajoutée.
### Secrets Forgejo du dépôt
| Secret | Contenu |
|---|---|
| `DEPLOY_SSH_KEY` | Clé privée `forgejo-runner@webapps` |
| `DEPLOY_KNOWN_HOSTS` | Sortie de `ssh-keyscan -p 2911 192.168.0.100` |
### Installer ou mettre à jour le script de déploiement
Sur la VM webapps, depuis le dépôt à jour :
```bash
sudo install -o root -g root -m 755 ops/deploy-gameservers-control.sh /usr/local/bin/deploy-gameservers-control
```
Le script :
1. prend un verrou, pour qu'un seul déploiement tourne à la fois ;
2. refuse de déployer si des fichiers suivis par git ont été modifiés à la main en prod ;
3. avance `main` jusqu'au commit demandé (avance rapide seulement, jamais de recul) ;
4. lance `npm ci --omit=dev`, redémarre le service, puis attend `/healthz` pendant 30 s ;
5. si `/healthz` ne répond pas, revient au commit précédent et termine en erreur.
## Données
`STORAGE_DIR` pointe hors du dépôt (`/data/webapps/data/gameservers-control`, droits `700`,
fichiers `600`).