diff --git a/.gitea/workflows/deploy-beta.yaml b/.gitea/workflows/deploy-beta.yaml new file mode 100644 index 0000000..1edf8ae --- /dev/null +++ b/.gitea/workflows/deploy-beta.yaml @@ -0,0 +1,68 @@ +name: Déploiement Frontend BETA +run-name: ${{ gitea.actor }} déploie Frontend BETA +on: + push: + branches: + - dev + +jobs: + test: + name: Lint et tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Installer les dépendances + run: yarn install --frozen-lockfile + + - name: Lint + run: yarn lint + + - name: Tests + run: yarn test + + deploy: + name: Déploiement beta + needs: test + runs-on: ubuntu-latest + steps: + - name: Déployer sur le serveur + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: ${{ secrets.SSH_PORT }} + script: | + set -e + cd ${{ secrets.DEPLOY_PATH }} + + echo "==> Correction des permissions" + sudo chown -R "$(whoami):" . + + echo "==> Synchronisation branche dev" + git fetch origin dev + git reset --hard origin/dev + + echo "==> Réseau Docker" + docker network inspect konstitisyon_network >/dev/null 2>&1 \ + || docker network create konstitisyon_network + + echo "==> Build et démarrage du frontend" + docker compose up -d --build + + echo "==> Vérification santé" + for i in $(seq 1 24); do + if curl -sf http://localhost:4000 | grep -q "html"; then + echo "Déploiement OK" + exit 0 + fi + echo " Attente... ($i/24)" + sleep 5 + done + echo "Échec : le frontend ne répond pas après 120s" + exit 1