Files
admin 209f81aa3d
🚀 Deploy — JH Photomaton / 🔍 Vérification (push) Has been cancelled
🚀 Deploy — JH Photomaton / 🍓 Deploy sur le Pi (push) Has been cancelled
first commit
2026-07-16 00:55:29 +02:00

113 lines
5.6 KiB
YAML

# ══════════════════════════════════════════════════════════════════════════════
# JH Photomaton — CI/CD Gitea Actions
# Déploiement automatique sur le Raspberry Pi via SSH
#
# SECRETS À CONFIGURER dans Gitea (Settings → Secrets) :
# PI_SSH_HOST → IP ou hostname du Pi (ex: 192.168.1.42 ou PiPhotobooth.local)
# PI_SSH_USER → pi
# PI_SSH_KEY → Clé privée SSH (voir docs/CI-CD-SETUP.md)
# PI_SSH_PORT → 22 (optionnel, 22 par défaut)
#
# PRÉREQUIS sur le Pi :
# - Le dépôt est cloné dans /home/pi/jh-photomaton
# - La règle sudoers est en place (scripts/sudoers-jh-photomaton)
# - Un runner Gitea Actions est configuré (voir docs/CI-CD-SETUP.md)
# ══════════════════════════════════════════════════════════════════════════════
name: 🚀 Deploy — JH Photomaton
on:
push:
branches:
- main
workflow_dispatch:
inputs:
force_install:
description: 'Forcer la réinstallation complète (install.sh)'
required: false
default: 'false'
type: choice
options:
- 'false'
- 'true'
jobs:
# ────────────────────────────────────────────────────────────────────────────
# Job 1 : Lint / vérification rapide avant deploy
# ────────────────────────────────────────────────────────────────────────────
lint:
name: 🔍 Vérification
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Installer les dépendances (sans paquets Pi-spécifiques)
run: |
pip install fastapi uvicorn jinja2 python-multipart itsdangerous httpx \
psutil aiosqlite pyyaml aiofiles pillow qrcode --quiet
- name: Vérification syntaxe Python
run: |
python -m py_compile main.py
python -m py_compile backend/services/config_service.py
python -m py_compile backend/services/led_service.py
python -m py_compile backend/services/button_service.py
python -m py_compile backend/services/photobooth_service.py
python -m py_compile backend/services/printer_service.py
python -m py_compile backend/services/system_service.py
echo "✅ Syntaxe Python OK"
# ────────────────────────────────────────────────────────────────────────────
# Job 2 : Déploiement SSH sur le Raspberry Pi
# ────────────────────────────────────────────────────────────────────────────
deploy:
name: 🍓 Deploy sur le Pi
runs-on: ubuntu-latest
needs: lint
steps:
- name: 🔑 Déploiement via SSH (mise à jour standard)
if: github.event.inputs.force_install != 'true'
uses: https://gitea.com/actions/appleboy-ssh-action@master
with:
host: ${{ secrets.PI_SSH_HOST }}
username: ${{ secrets.PI_SSH_USER }}
key: ${{ secrets.PI_SSH_KEY }}
port: ${{ secrets.PI_SSH_PORT || '22' }}
script_stop: true
script: |
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " JH Photomaton — Mise à jour"
echo " $(date '+%Y-%m-%d %H:%M:%S')"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
bash /home/pi/jh-photomaton/scripts/update.sh
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Déploiement terminé !"
- name: 🔧 Installation complète (force_install=true)
if: github.event.inputs.force_install == 'true'
uses: https://gitea.com/actions/appleboy-ssh-action@master
with:
host: ${{ secrets.PI_SSH_HOST }}
username: ${{ secrets.PI_SSH_USER }}
key: ${{ secrets.PI_SSH_KEY }}
port: ${{ secrets.PI_SSH_PORT || '22' }}
script_stop: true
script: |
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " JH Photomaton — Installation complète"
echo " $(date '+%Y-%m-%d %H:%M:%S')"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
cd /home/pi/jh-photomaton
git stash
git pull origin main
git stash pop || true
sudo bash /home/pi/jh-photomaton/scripts/install.sh
echo "✅ Installation complète terminée !"