-
Notifications
You must be signed in to change notification settings - Fork 5.5k
57 lines (46 loc) · 2.11 KB
/
feed-apply-migrations.yml
File metadata and controls
57 lines (46 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Apply database migrations
on:
push:
branches:
- staging
- production
concurrency:
group: apply-migrations-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
migrate:
runs-on: ubuntu-latest
env:
STAGING_DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
STAGING_DIRECT_DATABASE_URL: ${{ secrets.STAGING_DIRECT_DATABASE_URL }}
PROD_DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }}
PROD_DIRECT_DATABASE_URL: ${{ secrets.PROD_DIRECT_DATABASE_URL }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Apply migrations (staging)
if: github.ref == 'refs/heads/staging' && env.STAGING_DATABASE_URL != '' && env.STAGING_DIRECT_DATABASE_URL != ''
env:
DATABASE_URL: ${{ env.STAGING_DATABASE_URL }}
DIRECT_DATABASE_URL: ${{ env.STAGING_DIRECT_DATABASE_URL }}
working-directory: packages/feed/packages/db
run: bunx --bun drizzle-kit push --force --config=drizzle.config.ts
- name: Apply migrations (production)
if: github.ref == 'refs/heads/production' && env.PROD_DATABASE_URL != '' && env.PROD_DIRECT_DATABASE_URL != ''
env:
DATABASE_URL: ${{ env.PROD_DATABASE_URL }}
DIRECT_DATABASE_URL: ${{ env.PROD_DIRECT_DATABASE_URL }}
working-directory: packages/feed/packages/db
run: bunx --bun drizzle-kit push --force --config=drizzle.config.ts
- name: Skip notice (staging)
if: github.ref == 'refs/heads/staging' && (env.STAGING_DATABASE_URL == '' || env.STAGING_DIRECT_DATABASE_URL == '')
run: echo "Skipping staging migrations because STAGING_DATABASE_URL or STAGING_DIRECT_DATABASE_URL is not set."
- name: Skip notice (production)
if: github.ref == 'refs/heads/production' && (env.PROD_DATABASE_URL == '' || env.PROD_DIRECT_DATABASE_URL == '')
run: echo "Skipping production migrations because PROD_DATABASE_URL or PROD_DIRECT_DATABASE_URL is not set."