first commit
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
# CI/CD — Gitea Actions → Raspberry Pi
|
||||
|
||||
## Ce que ça fait
|
||||
|
||||
À chaque `git push` sur `main`, Gitea :
|
||||
1. Vérifie la syntaxe Python (`lint`)
|
||||
2. SSH sur le Pi → `git pull` + `pip install` + `systemctl restart`
|
||||
|
||||
Déclenchement manuel possible (avec option "installation complète").
|
||||
|
||||
---
|
||||
|
||||
## 1. Préparer le Pi
|
||||
|
||||
### Cloner le dépôt la première fois
|
||||
|
||||
```bash
|
||||
cd /home/pi
|
||||
git clone https://gitea.lespatas.ovh/admin/photoBooth.git jh-photomaton
|
||||
cd jh-photomaton
|
||||
sudo bash scripts/install.sh
|
||||
```
|
||||
|
||||
### Installer la règle sudoers (permet au CI de restart sans mot de passe)
|
||||
|
||||
```bash
|
||||
sudo cp scripts/sudoers-jh-photomaton /etc/sudoers.d/jh-photomaton
|
||||
sudo chmod 440 /etc/sudoers.d/jh-photomaton
|
||||
sudo visudo -c # doit afficher "parsed OK"
|
||||
```
|
||||
|
||||
### Générer une clé SSH dédiée au CI/CD
|
||||
|
||||
Sur le Pi :
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -C "gitea-cicd-jh-photomaton" -f ~/.ssh/gitea_deploy -N ""
|
||||
cat ~/.ssh/gitea_deploy.pub >> ~/.ssh/authorized_keys
|
||||
chmod 600 ~/.ssh/authorized_keys
|
||||
# Afficher la clé privée à copier dans Gitea :
|
||||
cat ~/.ssh/gitea_deploy
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Configurer les secrets dans Gitea
|
||||
|
||||
`Settings → Secrets and Variables → Actions → New Secret`
|
||||
|
||||
| Nom | Valeur |
|
||||
|-----|--------|
|
||||
| `PI_SSH_HOST` | IP du Pi (ex: `192.168.1.42`) ou hostname si résolvable depuis le serveur Gitea |
|
||||
| `PI_SSH_USER` | `pi` |
|
||||
| `PI_SSH_KEY` | Contenu de `~/.ssh/gitea_deploy` (clé **privée**, commence par `-----BEGIN...`) |
|
||||
| `PI_SSH_PORT` | `22` (optionnel) |
|
||||
|
||||
---
|
||||
|
||||
## 3. Configurer le runner Gitea Actions
|
||||
|
||||
Le workflow nécessite un runner Gitea Actions avec le label `ubuntu-latest`.
|
||||
|
||||
### Option A — Runner sur le serveur Gitea (recommandé)
|
||||
|
||||
Sur le serveur qui héberge Gitea :
|
||||
```bash
|
||||
# Télécharger l'act runner Gitea
|
||||
wget https://gitea.com/gitea/act_runner/releases/latest/download/act_runner-linux-amd64 -O act_runner
|
||||
chmod +x act_runner
|
||||
|
||||
# Enregistrer le runner (token dans Gitea : Settings → Actions → Runners)
|
||||
./act_runner register --instance https://gitea.lespatas.ovh \
|
||||
--token VOTRE_TOKEN --name "gitea-server" --labels "ubuntu-latest:docker://node:16-bullseye"
|
||||
|
||||
# Démarrer
|
||||
./act_runner daemon
|
||||
```
|
||||
|
||||
### Option B — Runner directement sur le Pi (plus simple, pas de Docker)
|
||||
|
||||
```bash
|
||||
wget https://gitea.com/gitea/act_runner/releases/latest/download/act_runner-linux-arm64 -O act_runner
|
||||
chmod +x act_runner
|
||||
./act_runner register --instance https://gitea.lespatas.ovh \
|
||||
--token VOTRE_TOKEN --name "pi-runner" --labels "ubuntu-latest:host"
|
||||
./act_runner daemon &
|
||||
```
|
||||
|
||||
> Avec `ubuntu-latest:host`, les jobs s'exécutent directement sur le Pi sans Docker.
|
||||
> Dans ce cas, le job SSH est superflu — on peut simplifier le workflow pour exécuter
|
||||
> `scripts/update.sh` directement.
|
||||
|
||||
---
|
||||
|
||||
## 4. Premier push et vérification
|
||||
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "feat: ajout CI/CD Gitea Actions"
|
||||
git push origin main
|
||||
```
|
||||
|
||||
Suivre l'exécution dans Gitea : `Repository → Actions`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Déclenchement manuel (avec installation forcée)
|
||||
|
||||
Dans Gitea : `Actions → Deploy — JH Photomaton → Run workflow`
|
||||
Choisir `force_install = true` pour relancer `install.sh` complet (re-pip, re-service).
|
||||
|
||||
---
|
||||
|
||||
## Résolution de problèmes
|
||||
|
||||
| Problème | Solution |
|
||||
|----------|----------|
|
||||
| `Host key verification failed` | Ajouter le Pi dans `~/.ssh/known_hosts` du runner |
|
||||
| `Permission denied (publickey)` | Vérifier que la clé publique est dans `authorized_keys` du Pi |
|
||||
| `sudo: systemctl: command not found` | Utiliser `/bin/systemctl` (déjà dans update.sh) |
|
||||
| `git stash pop` conflit | SSH sur le Pi, résoudre manuellement : `cd /home/pi/jh-photomaton && git checkout -- config/settings.yaml` |
|
||||
| Le runner ne démarre pas | Vérifier le token dans `gitea.lespatas.ovh/admin/photoBooth/settings/actions/runners` |
|
||||
Binary file not shown.
@@ -0,0 +1,105 @@
|
||||
# Migration Node-RED → JH Photomaton
|
||||
|
||||
## Ce que remplace JH Photomaton
|
||||
|
||||
| Fonctionnalité | Node-RED (avant) | JH Photomaton (après) |
|
||||
|---|---|---|
|
||||
| Bouton GPIO23 multi-clic | `button-events` node | `ButtonService` (gpiozero) |
|
||||
| Relay GPIO12 | Nœud GPIO | `ButtonService.relay_on/off()` |
|
||||
| NeoPixels GPIO18 | `rpi-neopixels` node | `LEDService` (rpi_ws281x) |
|
||||
| Webhooks photobooth-app | `/api/photobooth/` | `/api/webhook/photobooth` |
|
||||
| File d'attente impression | SQLite Node-RED | SQLite via `PrinterService` |
|
||||
| Dashboard admin | Node-RED Dashboard | `/admin` — FastAPI + HTML |
|
||||
| RAM consommée | ~150–300 Mo | ~30–80 Mo (objectif) |
|
||||
|
||||
## Étapes de migration
|
||||
|
||||
### 1. Installer JH Photomaton
|
||||
|
||||
```bash
|
||||
cd /home/pi/jh-photomaton
|
||||
sudo bash scripts/install.sh
|
||||
```
|
||||
|
||||
### 2. Mettre à jour plugin_commander.json
|
||||
|
||||
Remplacer `~/.config/photobooth-app/plugin_commander.json` par notre version :
|
||||
|
||||
```bash
|
||||
cp /home/pi/jh-photomaton/photobooth-app/config/plugin_commander_jh.json \
|
||||
~/.config/photobooth-app/plugin_commander.json
|
||||
```
|
||||
|
||||
Redémarrer photobooth-app :
|
||||
```bash
|
||||
sudo systemctl restart photobooth-app
|
||||
```
|
||||
|
||||
### 3. Mettre à jour le share_command "Demande d'impression"
|
||||
|
||||
Dans `~/.config/photobooth-app/config.json`, modifier l'action de partage :
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Demande d'impression",
|
||||
"processing": {
|
||||
"share_command": "curl 'http://127.0.0.1:8090/api/print/request?filename={filename}'"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ou utiliser la page `/admin/actions` de JH Photomaton pour éditer directement.
|
||||
|
||||
### 4. Désactiver Node-RED
|
||||
|
||||
```bash
|
||||
sudo systemctl stop nodered
|
||||
sudo systemctl disable nodered
|
||||
```
|
||||
|
||||
Gain RAM : ~150-300 Mo libérés.
|
||||
|
||||
### 5. Mettre à jour Zoraxy (optionnel)
|
||||
|
||||
Changer le sous-domaine `photomaton-nodered.lessapinsduweb.com` pour pointer vers `:8090` au lieu de `:1880`.
|
||||
|
||||
### 6. Démarrer JH Photomaton
|
||||
|
||||
```bash
|
||||
sudo systemctl start jh-photomaton
|
||||
sudo systemctl status jh-photomaton
|
||||
```
|
||||
|
||||
Accès admin : `http://photomaton-nodered.lessapinsduweb.com/admin`
|
||||
(ou `http://10.3.141.1:8090/admin` depuis le WiFi Photomaton)
|
||||
|
||||
## Vérification
|
||||
|
||||
```bash
|
||||
# Logs
|
||||
sudo journalctl -u jh-photomaton -f
|
||||
|
||||
# Test bouton (simulation)
|
||||
curl -X POST http://localhost:8090/api/system/button/simulate?clicks=1
|
||||
|
||||
# Test LED
|
||||
curl -X POST http://localhost:8090/api/leds/effect?effect=countdown
|
||||
|
||||
# Test webhook
|
||||
curl "http://localhost:8090/api/webhook/photobooth?event_key=counting&mediaitem_type=image"
|
||||
|
||||
# Statut système
|
||||
curl http://localhost:8090/api/system/stats
|
||||
```
|
||||
|
||||
## Rollback (retour Node-RED)
|
||||
|
||||
```bash
|
||||
sudo systemctl stop jh-photomaton
|
||||
sudo systemctl disable jh-photomaton
|
||||
sudo systemctl start nodered
|
||||
sudo systemctl enable nodered
|
||||
# Restaurer plugin_commander.json original
|
||||
cp ~/.config/photobooth-app/plugin_commander.json_backup-* ~/.config/photobooth-app/plugin_commander.json
|
||||
sudo systemctl restart photobooth-app
|
||||
```
|
||||
Reference in New Issue
Block a user