-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (85 loc) · 2.7 KB
/
db-push-migration.yaml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: db push migration
on:
push:
branches:
- main
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:54322/postgres
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
permissions:
contents: write
jobs:
filter:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
db: ${{ steps.changes.outputs.db }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: check for file changes
uses: dorny/paths-filter@v2
id: changes
with:
token: ${{ github.token }}
filters: .github/filter.yaml
push:
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID: ${{ secrets.SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID }}
SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET: ${{ secrets.SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET }}
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
needs: filter
if: needs.filter.outputs.db == 'true'
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_sha }}
token: ${{ secrets.PAT }}
- name: setup supabase cli
uses: supabase/setup-cli@v1
with:
version: latest
- name: setup node
uses: actions/setup-node@v3
with:
node-version-file: "package.json"
- name: setup pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
run_install: false
- name: setup pnpm environment variable
id: pnpm-env
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: cache pnpm dependencies
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-env.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-dependencies-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-dependencies-
- name: install dependencies
run: pnpm install --frozen-lockfile
- name: authenticate to supabase
run: pnpm supabase link --project-ref ${{ secrets.SUPABASE_REFERENCE_ID }}
- name: start local supabase
run: pnpm supabase start
- name: lint local db
run: pnpm supabase db lint
- name: deploy migration file to remote db
run: pnpm supabase db push
db-push-migration-check:
runs-on: ubuntu-latest
needs: push
if: ${{ ! failure() }}
steps:
- name: check
run: echo "test is successfully executed."