42 lines
1.5 KiB
YAML
42 lines
1.5 KiB
YAML
name: Deploy to home
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: [self-hosted, linux]
|
|
|
|
steps:
|
|
- name: Deploy via SSH
|
|
shell: bash
|
|
run: |
|
|
echo "Démarrage de la connexion et réplication Git native..."
|
|
|
|
ssh -o StrictHostKeyChecking=no -o BatchMode=yes -i /root/.ssh/id_home root@home.mesdonneesadministratives.fr "
|
|
cd /opt/alapatch &&
|
|
|
|
echo '=> [1/4] Configuration du Remote en SSH natif...' &&
|
|
# Configuration propre utilisant l'utilisateur générique 'git' de Gitea
|
|
git remote set-url origin git@git.mesdonneesadministratives.fr:cvancau/alapatch.git || git remote add origin git@git.mesdonneesadministratives.fr:cvancau/alapatch.git &&
|
|
|
|
echo '=> [2/4] Synchronisation Git native...' &&
|
|
git fetch --all &&
|
|
git reset --hard origin/main &&
|
|
git clean -fd &&
|
|
|
|
echo '=> [3/4] Build de l-image Docker (Node 22 / Vite)...' &&
|
|
docker build -t alapatch-prod . &&
|
|
|
|
echo '=> [4/4] Recyclage du conteneur sur le port 4321...' &&
|
|
if [ \$(docker ps -aq -f name=microkorg-editor) ]; then
|
|
docker stop microkorg-editor && docker rm microkorg-editor;
|
|
fi &&
|
|
docker run -d --restart unless-stopped -p 4321:4321 --name microkorg-editor alapatch-prod &&
|
|
|
|
echo '=> Déploiement terminé avec succès !'
|
|
"
|