Skip to content

Commit ea678cb

Browse files
authored
Merge pull request #133 from PolicyEngine/feat/ci-cd-improvements
Split CI/CD migrations into staging and production
2 parents d2a9c2c + 3947ced commit ea678cb

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,33 @@ jobs:
5252
run: uv run pytest -v -m "not integration and not staging"
5353

5454
# ── Stage 2: Build + Migrate + Infra (parallel) ───────────────
55-
migrate:
56-
name: Migrate database
55+
migrate-staging:
56+
name: Migrate staging database
57+
runs-on: ubuntu-latest
58+
needs: test
59+
if: ${{ !inputs.skip_staging }}
60+
environment: staging
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Install uv
67+
uses: astral-sh/setup-uv@v5
68+
69+
- name: Setup Python
70+
run: uv python install 3.13
71+
72+
- name: Sync dependencies
73+
run: uv sync
74+
75+
- name: Run database migrations
76+
env:
77+
SUPABASE_DB_URL: ${{ secrets.SUPABASE_DB_URL }}
78+
run: uv run alembic upgrade head
79+
80+
migrate-production:
81+
name: Migrate production database
5782
runs-on: ubuntu-latest
5883
needs: test
5984
environment: production
@@ -185,7 +210,7 @@ jobs:
185210
deploy-staging-modal:
186211
name: Deploy Modal to staging
187212
runs-on: ubuntu-latest
188-
needs: [migrate, setup-modal-environments]
213+
needs: [migrate-staging, setup-modal-environments]
189214
if: ${{ !inputs.skip_staging }}
190215
environment: staging
191216

@@ -256,7 +281,7 @@ jobs:
256281
--image=$IMAGE_URL:${{ github.sha }} \
257282
--tag=staging \
258283
--no-traffic \
259-
--update-env-vars=MODAL_ENVIRONMENT=staging,LOGFIRE_ENVIRONMENT=staging
284+
--update-env-vars=MODAL_ENVIRONMENT=staging,LOGFIRE_ENVIRONMENT=staging,SUPABASE_URL=${{ secrets.SUPABASE_URL }},SUPABASE_KEY=${{ secrets.SUPABASE_KEY }},SUPABASE_SECRET_KEY=${{ secrets.SUPABASE_SECRET_KEY }},SUPABASE_DB_URL=${{ secrets.SUPABASE_DB_URL }}
260285
261286
- name: Get staging URL
262287
id: get-staging-url
@@ -301,10 +326,10 @@ jobs:
301326
deploy-prod-modal:
302327
name: Deploy Modal to production
303328
runs-on: ubuntu-latest
304-
needs: [migrate, integration-tests]
329+
needs: [migrate-production, integration-tests]
305330
if: |
306331
always() &&
307-
needs.migrate.result == 'success' &&
332+
needs.migrate-production.result == 'success' &&
308333
(needs.integration-tests.result == 'success' || needs.integration-tests.result == 'skipped')
309334
environment: production
310335

changelog.d/133.changed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Split CI/CD database migrations into separate staging and production jobs with environment-scoped Supabase secrets

0 commit comments

Comments
 (0)