palico-bot/.forgejo/workflows/deploy.yml
Shinuwa e08dba41a3
All checks were successful
Deploy Palico Bot / check (push) Successful in 9s
Deploy Palico Bot / deploy (push) Successful in 6s
Fix vulnerable deps, shutdown and game server colours; tidy commands
Fixes:
- Update dependencies within their ranges: npm audit reported 8
  vulnerabilities (proxy-addr, multer, body-parser, undici...), now 0.
- Close open connections on shutdown: an open jukebox page kept its
  /api/events stream alive, so every restart waited for the 10 s
  forced exit and ended with code 1.
- Restore the ANSI escape characters of the game servers message, lost
  in a269824 (the status showed "[2;32mOnline[0m" as plain text). They
  are now written as \u001b so they cannot silently disappear again.
- Rename MusicQueue.listeners(), which shadowed EventEmitter's own
  listeners(eventName), to humanListeners().
- Deploy: check the VM's SSH host key (new DEPLOY_KNOWN_HOSTS secret)
  instead of StrictHostKeyChecking=no; run checks on push only, since
  PR branches are already checked by their push.

Commands:
- /listcommand is built from the loaded commands and their descriptions.
- /deletemsgs reports messages older than 14 days that it cannot delete.
- Vocal commands act on the caller's voice channel, falling back to
  VOICE_CHANNEL_ID.
- /maketeam accepts comma-separated names, so names can contain spaces.
- The game servers message is edited whenever its content changes, and
  a failed first update is retried instead of stopping the refresh.

Cleanup:
- Shared command loader (src/loadCommands.js); drop the unused
  "[disabled]" folders mechanism and the NODE_ENV requirement.
- SHINUWA_USER_ID becomes OWNER_USER_ID (the old name still works).
- One shuffle helper instead of three copies; remove dead code
  (validateAudioFile, PORT fallback, needless async).
- README: prerequisites first, consistent Node version, deploy secrets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 19:59:08 +01:00

59 lines
2 KiB
YAML

name: Deploy Palico Bot
# Les contrôles tournent à chaque push, sur toutes les branches (une PR est donc contrôlée par
# le push de sa branche) ; le déploiement, seulement après un push sur main dont les
# contrôles ont réussi.
on:
push:
jobs:
check:
runs-on: docker
# Image fixée ici : celle du label « docker » (node:20-bullseye) n'est plus maintenue,
# et son miroir de sécurité renvoie 404 (échec du run 4).
container:
image: node:24-bookworm
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Syntax checks and tests
run: npm run check
deploy:
needs: check
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: docker
container:
image: node:24-bookworm
steps:
- name: Deploy on WebApps
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
# Clé d'hôte de la VM (sortie de `ssh-keyscan -p 2911 192.168.0.100`) : sans elle,
# n'importe quelle machine qui répondrait à cette adresse recevrait la connexion.
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
run: |
# L'image contient déjà le client SSH ; ne l'installer que s'il manque.
if ! command -v ssh >/dev/null; then
apt-get update
apt-get install -y --no-install-recommends openssh-client
fi
if [ -z "$DEPLOY_KNOWN_HOSTS" ]; then
echo "Secret DEPLOY_KNOWN_HOSTS manquant (ssh-keyscan -p 2911 192.168.0.100)" >&2
exit 1
fi
mkdir -p ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/id_ed25519
ssh -o StrictHostKeyChecking=yes \
-i ~/.ssh/id_ed25519 \
-p 2911 \
shinuwa@192.168.0.100 \
"sudo /usr/local/bin/deploy-palico-bot"