Skip to content

Commit

Permalink
Add new workflow for supabase db migrations (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks committed Aug 11, 2023
1 parent 8cccbeb commit 7acb7a8
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 21 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: supabase/setup-cli@v1
with:
version: latest

- name: Start Supabase local development setup
run: supabase start

- name: Verify generated types are checked in
run: |
supabase gen types typescript --local > types.gen.ts
if ! git diff --ignore-space-at-eol --exit-code --quiet types.gen.ts; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
21 changes: 0 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ on:
- main

jobs:
database-migration:
name: Database migration
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
env:
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
steps:
- name: Checkout app
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
run: npm install -g pnpm && pnpm -v && pnpm i

- name: Check migration status
run: pnpm m:status

- name: Run migration
run: pnpm m:up

deploy:
name: Deploy app
runs-on: ubuntu-latest
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy Migrations to Production

on:
push:
branches:
- main
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.PRODUCTION_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.PRODUCTION_PROJECT_ID }}

steps:
- uses: actions/checkout@v3

- uses: supabase/setup-cli@v1
with:
version: latest

- run: supabase link --project-ref $SUPABASE_PROJECT_ID
- run: supabase db push
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"postgres": "^3.3.4",
"prettier": "~3.0.1",
"prettier-plugin-svelte": "^3.0.3",
"supabase": "1.85.0",
"svelte": "^4.1.2",
"svelte-check": "^3.4.3",
"svelte-preprocess": "^5.0.4",
Expand Down
141 changes: 141 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7acb7a8

Please sign in to comment.