-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaction.yml
68 lines (65 loc) · 2.5 KB
/
action.yml
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
name: 'Generate Supabase Database types'
author: 'Estee Tey'
description: 'Automatically updates your type definitions to match your table schemas'
inputs:
SUPABASE_REF_ID:
description: "Reference id of your Supabase project"
required: true
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'"
required: false
default: "src/types/supabase.ts"
runs:
using: composite
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
persist-credentials: true
fetch-depth: 0
- name: Set up supabase cli
uses: supabase/setup-cli@v1
with:
version: latest
- name: "Generate database typescript types"
shell: bash
env:
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: |
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:
file_pattern: ${{ inputs.OUTPUT_PATH }}
commit_message: Update database types
commit_user_name: Supabot
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_author: Supabot <41898282+github-actions[bot]@users.noreply.github.com>
branch: supabot/update-database-types
create_branch: true
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
github_token: ${{ github.token }}
source_branch: supabot/update-database-types
destination_branch: "main"
pr_allow_empty: false
pr_title: '[Supabot] Update database type definitions'
pr_body: |
- Auto-generated by [Supabot](https://github.com/lyqht/generate-supabase-db-types-github-action)
branding:
icon: 'activity'
color: 'blue'