diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 00000000..4bd0b00f --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,45 @@ +name: Deploy Backend to Staging + +on: + push: + branches: [main] + +concurrency: + group: deploy-backend + cancel-in-progress: true + +jobs: + deploy: + name: Deploy backend to staging + runs-on: self-hosted + steps: + - name: Pull latest code + run: | + cd /opt/encoach/encoach_backend_new_v2 + git fetch origin + git reset --hard origin/main + echo "Deployed: $(git log -1 --oneline)" + + - name: Rebuild and restart containers + run: | + cd /opt/encoach/encoach_backend_new_v2 + docker compose \ + -f docker-compose.yml \ + -f /opt/encoach/overrides/encoach.override.yml \ + up -d --build --remove-orphans + + - name: Smoke test + run: | + echo "Waiting 60s for Odoo to become healthy..." + sleep 60 + STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 http://localhost:8069/api/health) + if [ "$STATUS" != "200" ]; then + echo "ERROR: /api/health returned $STATUS" + exit 1 + fi + FE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 http://localhost:3000/) + if [ "$FE" != "200" ]; then + echo "ERROR: Frontend returned $FE" + exit 1 + fi + echo "All OK — Odoo=$STATUS Frontend=$FE"