ci: Run migrations inside K8s cluster after deploy

DB is internal to the cluster, so migrations must run via kubectl exec
into the scraper pod after deployment completes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kelly
2025-12-09 11:16:21 -07:00
parent a9b7a4d7a9
commit ec8ef6210c

View File

@@ -138,25 +138,7 @@ steps:
event: push
# ===========================================
# STAGE 3: Run Migrations (before deploy)
# ===========================================
run-migrations:
image: node:20
environment:
DATABASE_URL:
from_secret: database_url
commands:
- cd backend
- npm ci --prefer-offline
- npx tsx src/db/run-migrations.ts
depends_on:
- docker-backend
when:
branch: master
event: push
# ===========================================
# STAGE 4: Deploy (after migrations)
# STAGE 3: Deploy (after Docker builds)
# ===========================================
deploy:
image: bitnami/kubectl:latest
@@ -174,8 +156,10 @@ steps:
- kubectl set image deployment/findagram-frontend findagram-frontend=code.cannabrands.app/creationshop/findagram-frontend:${CI_COMMIT_SHA:0:8} -n dispensary-scraper
- kubectl rollout status deployment/scraper -n dispensary-scraper --timeout=300s
- kubectl rollout status deployment/cannaiq-frontend -n dispensary-scraper --timeout=120s
# Run migrations inside the cluster after deploy
- kubectl exec deployment/scraper -n dispensary-scraper -- npx tsx src/db/run-migrations.ts
depends_on:
- run-migrations
- docker-backend
- docker-cannaiq
- docker-findadispo
- docker-findagram