-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add supabase-cli types generation * Bump cli 1.5.3 - setup-cli 1.0.2 * Update Readme example for use with supabase-cli * chore: update docs for autogen on db update * update docs for migration from v0.1.0 to v0.2.0 * update indent in yml examples * update docs to be explicit in affected types * add doc for how to get sb access token * add description for migration script use case * update checkout action to v3 * update action to run supabase init and start to create config.toml * init and start only for the first run Co-authored-by: lyqht <[email protected]>
- Loading branch information
1 parent
60721a1
commit 86b729b
Showing
5 changed files
with
508 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,14 @@ author: 'Estee Tey' | |
description: 'Automatically updates your type definitions to match your table schemas' | ||
|
||
inputs: | ||
SUPABASE_ANON_KEY: | ||
description: "Anonymous API key of your Supabase project" | ||
SUPABASE_REF_ID: | ||
description: "Reference id of your Supabase project" | ||
required: true | ||
SUPABASE_URL: | ||
description: "Endpoint of your Supabase project" | ||
SUPABASE_ACCESS_TOKEN: | ||
description: "Access token https://app.supabase.com/account/tokens" | ||
required: true | ||
DB_PASSWORD: | ||
description: "Database password" | ||
required: true | ||
OUTPUT_PATH: | ||
description: "Path where you want the definitions file to be saved. Any changes will be committed and override existing definition files. Default value is 'src/types/supabase.ts'" | ||
|
@@ -18,21 +21,27 @@ runs: | |
using: composite | ||
steps: | ||
- name: Checkout project | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: true | ||
fetch-depth: 0 | ||
- name: Set up node | ||
uses: actions/[email protected] | ||
- name: "Retrieve OpenAPI specifications of Supabase project" | ||
- name: Set up supabase cli | ||
uses: supabase/[email protected] | ||
with: | ||
version: 1.5.3 | ||
- name: "Generate database typescript types" | ||
shell: bash | ||
env: | ||
SUPABASE_URL: ${{ inputs.SUPABASE_URL }} | ||
SUPABASE_ANON_KEY: ${{ inputs.SUPABASE_ANON_KEY }} | ||
SUPABASE_REF_ID: ${{ inputs.SUPABASE_REF_ID }} | ||
SUPABASE_ACCESS_TOKEN: ${{ inputs.SUPABASE_ACCESS_TOKEN }} | ||
DB_PASSWORD: ${{ inputs.DB_PASSWORD }} | ||
OUTPUT_PATH: ${{ inputs.OUTPUT_PATH }} | ||
run: | | ||
npx openapi-typescript ${SUPABASE_URL}/rest/v1/?apikey=${SUPABASE_ANON_KEY} --version=2 --output ${OUTPUT_PATH} | ||
echo "$(cat src/types/supabase.ts)" | ||
if [ ! -f supabase/config.toml ]; then | ||
supabase init && supabase start | ||
fi | ||
supabase link --project-ref ${SUPABASE_REF_ID} --password ${DB_PASSWORD} | ||
supabase gen types typescript --db-url "postgresql://postgres:${DB_PASSWORD}@db.${SUPABASE_REF_ID}.supabase.co:6543/postgres" > ${OUTPUT_PATH} | ||
- name: Check for file changes & commit files | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
|
@@ -56,4 +65,4 @@ runs: | |
branding: | ||
icon: 'activity' | ||
color: 'blue' | ||
color: 'blue' |
Oops, something went wrong.