@@ -116,61 +116,18 @@ jobs:
116116 needs : [lint, test-unit, test-e2e]
117117
118118 steps :
119- - name : Checkout code
120- uses : actions/checkout@v4
121-
122- - name : Deploy via SSH
123- uses : appleboy/ssh-action@v1.0.3
124- with :
125- host : ${{ secrets.VPS_HOST }}
126- username : ${{ secrets.VPS_USER }}
127- key : ${{ secrets.VPS_SSH_KEY }}
128- port : 22
129- command_timeout : 30m
130- script : |
131- set -e
132- echo "🚀 Déploiement Lucky7 — staging"
133-
134- REPO_DIR="/var/www/Lucky7"
135- COMPOSE_FILE="/var/www/docker-compose.yml"
136-
137- # ── Cloner ou mettre à jour le repo ──────────────────────────
138- if [ ! -d "$REPO_DIR/.git" ]; then
139- echo "📥 Premier déploiement — clonage du repo..."
140- git clone https://github.com/${{ github.repository }}.git "$REPO_DIR"
141- git -C "$REPO_DIR" checkout staging
142- else
143- echo "🔄 Mise à jour du code..."
144- git -C "$REPO_DIR" fetch origin staging
145- git -C "$REPO_DIR" reset --hard origin/staging
146- fi
147- echo "✅ Code à jour"
148-
149- # ── Vérifier que le .env backend existe ───────────────────────
150- ENV_FILE="$REPO_DIR/lucky7-app/backend/.env"
151- if [ ! -f "$ENV_FILE" ]; then
152- echo "❌ Fichier .env manquant : $ENV_FILE"
153- echo " Créez-le manuellement sur le VPS avant de déployer."
154- exit 1
155- fi
156- echo "✅ Fichier .env backend trouvé"
157-
158- # ── Rebuild et restart uniquement les services Lucky7 ─────────
159- echo "🔨 Build des images..."
160- docker-compose -f "$COMPOSE_FILE" build lucky7-back lucky7-front
161-
162- echo "🔄 Redémarrage des containers..."
163- docker-compose -f "$COMPOSE_FILE" up -d --remove-orphans lucky7-back lucky7-front
164-
165- echo "✅ Containers démarrés"
166-
167- # ── Nettoyage des images obsolètes ────────────────────────────
168- docker image prune -f
169-
170- # ── Vérification finale ───────────────────────────────────────
171- echo ""
172- echo "📊 État des containers Lucky7 :"
173- docker ps --filter "name=lucky7-" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
174-
175- echo ""
176- echo "🎉 Déploiement terminé !"
119+ - name : Trigger update via vps-monitor
120+ run : |
121+ curl -sf -c cookies.txt \
122+ -X POST "${{ secrets.VPS_MONITOR_URL }}/auth/login" \
123+ -H "Content-Type: application/json" \
124+ -d '{"username":"${{ secrets.VPS_MONITOR_USER }}","password":"${{ secrets.VPS_MONITOR_PASS }}"}' \
125+ | grep -q '"ok":true' || { echo "Échec login vps-monitor"; exit 1; }
126+
127+ curl -sf -b cookies.txt \
128+ -X POST "${{ secrets.VPS_MONITOR_URL }}/api/deploy/update" \
129+ -H "Content-Type: application/json" \
130+ -d '{"name":"Lucky7"}' \
131+ | grep -q '"ok":true' || { echo "Échec update vps-monitor"; exit 1; }
132+
133+ echo "Déploiement déclenché : http://78.138.58.95/Lucky7/"
0 commit comments