Skip to content

Commit

Permalink
Added github ci/cd for supabase db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
G-structure committed Apr 3, 2023
1 parent f9f3470 commit 3ee06b2
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- uses: supabase/setup-cli@v1

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

- name: Verify generated types are up-to-date
run: |
supabase gen types typescript --local > types.ts
if [ "$(git diff --ignore-space-at-eol types.ts | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
25 changes: 25 additions & 0 deletions .github/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy Migrations to Production

on:
push:
branches:
- main
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-22.04

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

steps:
- uses: actions/checkout@v3

- uses: supabase/setup-cli@v1

- run: |
supabase link --project-ref $PRODUCTION_PROJECT_ID
supabase db push
25 changes: 25 additions & 0 deletions .github/staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy Migrations to Staging

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-22.04

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.STAGING_DB_PASSWORD }}
STAGING_PROJECT_ID: abcdefghijklmnopqrst

steps:
- uses: actions/checkout@v3

- uses: supabase/setup-cli@v1

- run: |
supabase link --project-ref $STAGING_PROJECT_ID
supabase db push

0 comments on commit 3ee06b2

Please sign in to comment.