-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (62 loc) · 2.08 KB
/
supabase-preview.yml
File metadata and controls
69 lines (62 loc) · 2.08 KB
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
name: Supabase Preview Branch
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
jobs:
create-preview-branch:
name: Create Supabase Preview Branch
runs-on: ubuntu-latest
if: github.event.action != 'closed'
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Create Supabase Preview Branch
run: |
if [ -z "$SUPABASE_ACCESS_TOKEN" ]; then
echo "SUPABASE_ACCESS_TOKEN is not set, skipping branch creation."
exit 0
fi
supabase --experimental branches create \
--project-ref vhgwvfedgfmcixhdyttt \
--name "${{ github.head_ref }}" || \
echo "Branch creation failed or branch already exists, continuing..."
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
delete-preview-branch:
name: Delete Supabase Preview Branch
runs-on: ubuntu-latest
if: github.event.action == 'closed'
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Delete Supabase Preview Branch
run: |
if [ -z "$SUPABASE_ACCESS_TOKEN" ]; then
echo "SUPABASE_ACCESS_TOKEN is not set, skipping branch deletion."
exit 0
fi
BRANCH_NAME="${{ github.head_ref }}"
BRANCH_ID=$(supabase --experimental branches list \
--project-ref vhgwvfedgfmcixhdyttt \
--output json 2>/dev/null | \
jq -r --arg name "$BRANCH_NAME" '.[] | select(.name == $name) | .id' 2>/dev/null || true)
if [ -n "$BRANCH_ID" ]; then
supabase --experimental branches delete "$BRANCH_ID" \
--project-ref vhgwvfedgfmcixhdyttt || true
else
echo "No Supabase branch found for git branch: $BRANCH_NAME"
fi
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}