-
-
Notifications
You must be signed in to change notification settings - Fork 56
171 lines (164 loc) · 5.51 KB
/
build_and_deploy.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Build source code and send to Capgo
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
tags:
- '*'
jobs:
supabase_deploy:
runs-on: ubuntu-latest
name: "Build code and deploy to Supabase"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Set environment variable
run: |
if [[ ${{ github.ref }} == *-alpha* ]]; then
echo "ENV=alpha" >> $GITHUB_ENV
else
echo "ENV=prod" >> $GITHUB_ENV
fi
- name: Set Supabase credentials
run: |
echo "SUPABASE_DB_PASSWORD=${{ secrets[format('SUPABASE_DB_PASS_{0}', env.ENV)] }}" >> $GITHUB_ENV
echo "SUPABASE_PROJECT_ID=${{ secrets[format('SUPABASE_PROJECT_ID_{0}', env.ENV)] }}" >> $GITHUB_ENV
- name: Install dependencies
run: bun install
- name: Lint
run: bun lint && bun lint-backend
- name: Install Supabase CLI
uses: supabase/setup-cli@v1
with:
version: latest
- name: Prepare Supabase
run: supabase link --project-ref ${{ env.SUPABASE_PROJECT_ID }}
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_TOKEN }}
# - name: Wait for tests to succeed
# uses: lewagon/[email protected]
# with:
# ref: ${{ github.ref }}
# check-name: 'Run tests'
# repo-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
# wait-interval: 10
- name: Apply Supabase Migrations
run: supabase db push
- name: Update functions
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_TOKEN }}
run: supabase functions deploy
deploy_webapp:
needs: supabase_deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Set environment variable
run: |
if [[ ${{ github.ref }} == *-alpha* ]]; then
echo "ENV=alpha" >> $GITHUB_ENV
echo "PROJECT_NAME=capgo-webapp-preprod" >> $GITHUB_ENV
echo "CHANNEL=alpha" >> $GITHUB_ENV
else
echo "ENV=prod" >> $GITHUB_ENV
echo "PROJECT_NAME=capgo-webapp" >> $GITHUB_ENV
echo "CHANNEL=production" >> $GITHUB_ENV
fi
- name: Build
run: bun ${{ env.ENV == 'prod' && 'mobile' || 'dev-mobile' }}
env:
VITE_VAPID_KEY: ${{ secrets.VITE_VAPID_KEY }}
VITE_FIREBASE_CONFIG: ${{ secrets.VITE_FIREBASE_CONFIG }}
- name: Publish CF webapp
run: bunx wrangler@latest pages deploy dist --project-name ${{ env.PROJECT_NAME }} --branch main
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy to Capgo
run: bunx @capgo/cli@latest bundle upload -a ${{ secrets.CAPGO_TOKEN }} --channel ${{ env.CHANNEL }} --partial --tus
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
deploy_api:
needs: supabase_deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Set environment variable
run: |
if [[ ${{ github.ref }} == *-alpha* ]]; then
echo "ENV=alpha" >> $GITHUB_ENV
else
echo "ENV=prod" >> $GITHUB_ENV
fi
- name: Deploy CF Worker API
run: bun run deploy:cloudflare:api:${{ env.ENV }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
deploy_files:
needs: supabase_deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Set environment variable
run: |
if [[ ${{ github.ref }} == *-alpha* ]]; then
echo "ENV=alpha" >> $GITHUB_ENV
else
echo "ENV=prod" >> $GITHUB_ENV
fi
- name: Deploy CF Worker Files
run: bun run deploy:cloudflare:files:${{ env.ENV }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
deploy_plugin:
needs: supabase_deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Set environment variable
run: |
if [[ ${{ github.ref }} == *-alpha* ]]; then
echo "ENV=alpha" >> $GITHUB_ENV
else
echo "ENV=prod" >> $GITHUB_ENV
fi
- name: Deploy CF Worker Plugin
run: bun run deploy:cloudflare:plugin:${{ env.ENV }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}