From 85e761d0d67a65700719095e3f37fb2bad4e4fb3 Mon Sep 17 00:00:00 2001 From: liquidrinu Date: Wed, 21 May 2025 22:05:31 +0200 Subject: [PATCH] update k8s config --- .gitea-ci.yml | 14 ++++++++++++++ README.md | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/.gitea-ci.yml b/.gitea-ci.yml index 4399050..bc7a7d4 100644 --- a/.gitea-ci.yml +++ b/.gitea-ci.yml @@ -67,6 +67,10 @@ jobs: CANVAS_API_KEY: "${{ secrets.CANVAS_API_KEY }}" EOF + - name: Delete old migration/seed job + run: | + kubectl delete job fusero-backend-db-init -n fusero-prod || true + - name: Deploy to Kubernetes run: | helm upgrade --install fusero ./chart \ @@ -77,6 +81,16 @@ jobs: --set backend.image.repository=registry.liquidrinu.com/fusero-backend \ --set frontend.image.repository=registry.liquidrinu.com/fusero-frontend + - name: Wait for migration/seed job + run: | + kubectl wait --for=condition=complete --timeout=300s job/fusero-backend-db-init -n fusero-prod + JOB_STATUS=$(kubectl get job fusero-backend-db-init -n fusero-prod -o jsonpath='{.status.succeeded}') + if [ "$JOB_STATUS" != "1" ]; then + echo "Migration/seed job failed!" >&2 + kubectl logs job/fusero-backend-db-init -n fusero-prod + exit 1 + fi + - name: Verify Deployment run: | kubectl rollout status deployment/fusero-backend -n fusero-prod diff --git a/README.md b/README.md index 01049ed..46bfc59 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ A full-stack application boilerplate with a React frontend and Node.js backend - [CI/CD \& Automated Testing](#cicd--automated-testing) - [Troubleshooting Production](#troubleshooting-production) - [🆕 Recent Improvements \& Troubleshooting](#-recent-improvements--troubleshooting) + - [🚀 Production Deployment Pipeline (CI/CD)](#-production-deployment-pipeline-cicd) --- @@ -821,3 +822,18 @@ The application uses a secure secrets management approach: ``` --- + +## 🚀 Production Deployment Pipeline (CI/CD) + +- On every push/merge to `main`, the Gitea CI/CD pipeline will: + 1. Build and push Docker images for backend and frontend. + 2. Generate `secrets.prod.yaml` from Gitea CI/CD secrets. + 3. **Delete the old migration/seed job** (`fusero-backend-db-init`) to ensure a fresh run. + 4. Deploy the app with Helm, which triggers the migration/seed job. + 5. **Wait for the migration/seed job to complete.** + 6. **Fail the pipeline if the job fails** (with logs for debugging). + 7. Verify the deployment. + +- This ensures your database is always migrated and seeded with every deploy, and you'll know immediately if something goes wrong. + +- To trigger a production deployment, just push or merge to `main`.