diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 339a194..1d1c494 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Deploy to home +name: Deploy to home (Isolated Port) on: push: @@ -11,18 +11,34 @@ jobs: runs-on: [self-hosted, linux] steps: - - name: Deploy via SSH + # 1. Récupération du code source sur le Runner + - name: Checkout Code + uses: actions/checkout@v4 + + # 2. Compilation de l'application sur le Runner Gitea + - name: Build Application Locally run: | - ssh -o StrictHostKeyChecking=no -i /root/.ssh/id_home root@home.mesdonneesadministratives.fr " - cd /opt/alapatch && - git fetch --all && - # Correction ici : on force l'alignement sur origin/main - git reset --hard origin/main && - docker build --no-cache -t alapatch-prod . && - if [ \$(docker ps -aq -f name=microkorg-editor) ]; then - docker stop microkorg-editor && - docker rm microkorg-editor + npm install --legacy-peer-deps + npm run build + + # 3. Déploiement isolé vers le serveur home + - name: Deploy to Isolated Directory + run: | + # Envoie le dossier build compilé dans un répertoire dédié /opt/alapatch-dist + tar -czf - -C build . | ssh -o StrictHostKeyChecking=no -i /root/.ssh/id_home root@home.mesdonneesadministratives.fr " + mkdir -p /opt/alapatch-dist && + tar -xzf - -C /opt/alapatch-dist && + + # Installe l'utilitaire http-server globalement si absent pour gérer le port + if ! command -v http-server &> /dev/null; then + npm install -g http-server fi && - docker run -d --restart unless-stopped -p 4321:4321 --name microkorg-editor alapatch-prod + + # Arrête proprement l'ancien serveur de test s'il tourne sur le port 4321 + fuser -k 4321/tcp || true && + + # Lance le serveur en arrière-plan sur le port 4321 + nohup http-server /opt/alapatch-dist -p 4321 -a 0.0.0.0 > /dev/null 2>&1 & " +