-
Notifications
You must be signed in to change notification settings - Fork 78
579 lines (509 loc) · 21.9 KB
/
gcp-deploy-pr.yaml
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
name: Deploy Preview to Cloud Run
on:
workflow_dispatch:
inputs:
cache_key:
description: Optional cache key component to force invalidation of the build cache.
required: false
default: ""
pull_request:
types:
- opened
- reopened
- synchronize
env:
# This controls whether the Next.js runs in development or
# production mode. For debugging test instance only bugs.
FRONTEND_TARGET: production # development
PROJECT_ID: metagame-thegame
REGISTRY_REGION: us-east4
REGISTRY_REPO: thegame
DEPLOYMENT_DOMAIN: a.run.app
CLOUDRUN_SUFFIX: mjhnbmqqna-uk
DEPLOYMENT_NAME: Test-PR-${{github.event.number}}
DB_NAME: hasura-pr-${{github.event.number}}
BACKEND_SERVICE: backend-pr-${{github.event.number}}
FRONTEND_SERVICE: frontend-pr-${{github.event.number}}
BACKEND_PORT: 4000
HASURA_PORT: 8080
FRONTEND_PORT: 3000
HASURA_SECRET: metagame_secret
APP_ENV: development
jobs:
start-deployment:
name: Generate Deployment Start Message
runs-on: ubuntu-latest
outputs:
deployment_id: ${{steps.create-message.outputs.deployment_id}}
steps:
- name: Start Deployment
uses: bobheadxi/deployments@v1
id: create-message
with:
step: start
token: ${{github.token}}
env: ${{env.DEPLOYMENT_NAME}}
desc: "Test instance deployment for PR #${{github.event.number}} of ${{github.event.pull_request.head.label}} by ${{github.event.pull_request.user.login}}"
ref: ${{github.head_ref}}
auto_inactive: false
logs: https://github.com/${{github.repository}}/commit/${{github.event.after}}/checks
cancel-previous:
name: Cancel Existing Runs
runs-on: ubuntu-latest
steps:
- name: Cancel Existing Runs
uses: styfle/[email protected]
with:
access_token: ${{github.token}}
env:
name: Environment Variables
runs-on: ubuntu-latest
outputs:
APP_ENV: ${{env.APP_ENV}}
PROJECT_ID: ${{env.PROJECT_ID}}
REGISTRY_REGION: ${{env.REGISTRY_REGION}}
REGISTRY_REPO: ${{env.REGISTRY_REPO}}
DEPLOYMENT_DOMAIN: ${{env.DEPLOYMENT_DOMAIN}}
CLOUDRUN_SUFFIX: ${{env.CLOUDRUN_SUFFIX}}
DB_NAME: ${{env.DB_NAME}}
BACKEND_SERVICE: ${{env.BACKEND_SERVICE}}
FRONTEND_SERVICE: ${{env.FRONTEND_SERVICE}}
BACKEND_PORT: ${{env.BACKEND_PORT}}
HASURA_PORT: ${{env.HASURA_PORT}}
FRONTEND_PORT: ${{env.FRONTEND_PORT}}
HASURA_SECRET: ${{env.HASURA_SECRET}}
CLOUDRUN_REGION: ${{env.CLOUDRUN_REGION}}
CLOUDSQL_INSTANCE_NAME: ${{env.CLOUDSQL_INSTANCE_NAME}}
CLOUDSQL_CONNECTION_NAME: ${{env.CLOUDSQL_CONNECTION_NAME}}
HASURA_SERVICE: ${{env.HASURA_SERVICE}}
DOCKER_REGISTRY: ${{env.DOCKER_REGISTRY}}
BACKEND_HOST: ${{env.BACKEND_HOST}}
REMOTE_SCHEMA_ENDPOINT: "${{env.BACKEND_URL}}/remote-schemas/graphql"
FRONTEND_URL: ${{env.FRONTEND_URL}}
DB_PASSWORD: ${{env.DB_PASSWORD}}
HASURA_HOST: ${{env.HASURA_HOST}}
DOCKER_PATH: ${{env.DOCKER_PATH}}
SC_SYNC_URL: ${{env.SC_SYNC_URL}}
DB_HOST: ${{env.DB_HOST}}
GRAPHQL_URL: ${{env.GRAPHQL_URL}}
BACKEND_TAG: ${{env.BACKEND_TAG}}
HASURA_TAG: ${{env.HASURA_TAG}}
FRONTEND_TAG: ${{env.FRONTEND_TAG}}
FRONTEND_TARGET: ${{env.FRONTEND_TARGET}}
steps:
- name: First Intepolation of Variables
id: first
run: |
echo "CLOUDRUN_REGION=${{env.REGISTRY_REGION}}" >> $GITHUB_ENV
echo "CLOUDSQL_INSTANCE_NAME=${{env.REGISTRY_REPO}}" >> $GITHUB_ENV
echo "CLOUDSQL_CONNECTION_NAME=\
${{env.PROJECT_ID}}:${{env.REGISTRY_REGION}}:${{env.REGISTRY_REPO}}" >> $GITHUB_ENV
echo "HASURA_SERVICE=${{env.DB_NAME}}" >> $GITHUB_ENV
echo "DOCKER_REGISTRY=${{env.REGISTRY_REGION}}-docker.pkg.dev" >> $GITHUB_ENV
echo "BACKEND_HOST=\
${{env.BACKEND_SERVICE}}-${{env.CLOUDRUN_SUFFIX}}.${{env.DEPLOYMENT_DOMAIN}}" >> $GITHUB_ENV
echo "FRONTEND_URL=\
https://${{env.FRONTEND_SERVICE}}-${{env.CLOUDRUN_SUFFIX}}.${{env.DEPLOYMENT_DOMAIN}}" >> $GITHUB_ENV
echo "DB_PASSWORD=$(head -c 48 /dev/urandom | tr -cd [:alnum:])" >> $GITHUB_ENV
echo "FRONTEND_TARGET=${{env.FRONTEND_TARGET}}" >> $GITHUB_ENV
- name: Those Variables May Now Be Interpolated
id: second
run: |
echo "HASURA_HOST=\
${{env.HASURA_SERVICE}}-${{env.CLOUDRUN_SUFFIX}}.${{env.DEPLOYMENT_DOMAIN}}" >> $GITHUB_ENV
echo "DOCKER_PATH=\
${{env.DOCKER_REGISTRY}}/${{env.PROJECT_ID}}/${{env.REGISTRY_REPO}}" >> $GITHUB_ENV
echo "BACKEND_URL=https://${{env.BACKEND_HOST}}" >> $GITHUB_ENV
echo "SC_SYNC_URL=\
https://${{env.BACKEND_HOST}}/actions/syncSourceCredAccounts?force=true" >> $GITHUB_ENV
echo "DB_HOST=\
/${{env.DB_NAME}}?host=/cloudsql/${{env.CLOUDSQL_CONNECTION_NAME}}" >> $GITHUB_ENV
- name: And That Result Again In Another Step
id: third
run: |
echo "GRAPHQL_URL=\
https://${{env.HASURA_HOST}}/v1/graphql" >> $GITHUB_ENV
echo "BACKEND_TAG=\
${{env.DOCKER_PATH}}/backend:pr-${{github.event.number}}" >> $GITHUB_ENV
echo "HASURA_TAG=\
${{env.DOCKER_PATH}}/hasura:pr-${{github.event.number}}" >> $GITHUB_ENV
echo "FRONTEND_TAG=\
${{env.DOCKER_PATH}}/frontend:pr-${{github.event.number}}" >> $GITHUB_ENV
delete-db:
name: Delete SQL User & Database
runs-on: ubuntu-latest
needs: [env]
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Delete SQL User: ${{needs.env.outputs.DB_NAME}}"
continue-on-error: true
run: |
gcloud -q sql users delete ${{needs.env.outputs.DB_NAME}} \
-i ${{needs.env.outputs.CLOUDSQL_INSTANCE_NAME}}
- name: "Delete Database: ${{needs.env.outputs.DB_NAME}}"
continue-on-error: true
run: |
wget -q https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
chmod u+x cloud_sql_proxy
./cloud_sql_proxy -instances ${{needs.env.outputs.CLOUDSQL_CONNECTION_NAME}} \
-dir /tmp/cloudsql &
PID=$!
sleep 10
PGPASSWORD=${{secrets.GCP_POSTGRES_PASSWORD}} \
dropdb -h /tmp/cloudsql/${{needs.env.outputs.CLOUDSQL_CONNECTION_NAME}} \
-U postgres ${{needs.env.outputs.DB_NAME}} -f
kill $PID
create-db:
name: Create New SQL User & Database
runs-on: ubuntu-latest
needs: [env, delete-db]
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Create SQL User: ${{needs.env.outputs.DB_NAME}}"
run: |
gcloud -q sql users create ${{needs.env.outputs.DB_NAME}} \
-i ${{needs.env.outputs.CLOUDSQL_INSTANCE_NAME}} \
--password ${{needs.env.outputs.DB_PASSWORD}}
- name: "Create Database: ${{needs.env.outputs.DB_NAME}}"
run: |
gcloud -q sql databases create ${{needs.env.outputs.DB_NAME}} \
-i ${{needs.env.outputs.CLOUDSQL_INSTANCE_NAME}}
undeploy-backend:
name: Undeploy Backend
runs-on: ubuntu-latest
needs: [env]
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Delete Service: ${{needs.env.outputs.BACKEND_SERVICE}}"
continue-on-error: true
run: |
gcloud -q run services delete ${{needs.env.outputs.BACKEND_SERVICE}} \
--region ${{needs.env.outputs.CLOUDRUN_REGION}}
delete-backend:
name: Delete Backend Container Image
runs-on: ubuntu-latest
needs: [env]
steps:
- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v2
with:
registry: ${{needs.env.outputs.DOCKER_REGISTRY}}
username: _json_key
password: ${{secrets.GCP_SA_KEY}}
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Delete Container Image: ${{needs.env.outputs.BACKEND_TAG}}"
continue-on-error: true
run: gcloud -q artifacts docker images delete ${{needs.env.outputs.BACKEND_TAG}}
build-backend:
name: Build Backend Container Image
runs-on: ubuntu-latest
needs: [env, delete-backend, undeploy-backend]
steps:
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v3
with:
registry: ${{needs.env.outputs.DOCKER_REGISTRY}}
username: _json_key
password: ${{secrets.GCP_SA_KEY}}
- name: "Build & Push Container Image: ${{needs.env.outputs.BACKEND_TAG}}"
uses: docker/build-push-action@v5
with:
file: docker/backend/Dockerfile
tags: ${{needs.env.outputs.BACKEND_TAG}}
build-args: |
GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}} \
THE_GRAPH_API_TOKEN=${{secrets.THE_GRAPH_API_TOKEN}}
push: true
deploy-backend:
name: Deploy Backend
runs-on: ubuntu-latest
needs: [env, create-db, build-backend]
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Deploy Container Image: ${{needs.env.outputs.BACKEND_TAG}}"
run: |
gcloud -q run deploy ${{needs.env.outputs.BACKEND_SERVICE}} \
--image ${{needs.env.outputs.BACKEND_TAG}} \
--region ${{needs.env.outputs.CLOUDRUN_REGION}} \
--port ${{needs.env.outputs.BACKEND_PORT}} \
--cpu 1 \
--memory 768Mi \
--ingress all \
--allow-unauthenticated \
--max-instances 1 \
--set-env-vars HASURA_GRAPHQL_ADMIN_SECRET=${{needs.env.outputs.HASURA_SECRET}} \
--set-env-vars GITHUB_API_TOKEN=${{secrets.GH_API_TOKEN}} \
--set-env-vars SOURCECRED_LEDGER_BRANCH=master \
--set-env-vars GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}} \
--set-env-vars DISCORD_BOT_TOKEN=${{secrets.DISCORD_BOT_TOKEN}} \
--set-env-vars THE_GRAPH_API_TOKEN=${{secrets.THE_GRAPH_API_TOKEN}} \
--set-env-vars CERAMIC_URL=https://ceramic.metagame.wtf
undeploy-hasura:
name: Undeploy Hasura
runs-on: ubuntu-latest
needs: [env]
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Delete Service: ${{needs.env.outputs.HASURA_SERVICE}}"
continue-on-error: true
run: |
gcloud -q run services delete ${{needs.env.outputs.HASURA_SERVICE}} \
--region ${{needs.env.outputs.CLOUDRUN_REGION}}
delete-hasura:
name: Delete Hasura Container Image
runs-on: ubuntu-latest
needs: [env]
steps:
- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v2
with:
registry: ${{needs.env.outputs.DOCKER_REGISTRY}}
username: _json_key
password: ${{secrets.GCP_SA_KEY}}
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Delete Container Image: ${{needs.env.outputs.HASURA_TAG}}"
continue-on-error: true
run: gcloud -q artifacts docker images delete ${{needs.env.outputs.HASURA_TAG}}
build-hasura:
name: Build Hasura Container Image
runs-on: ubuntu-latest
needs: [env, delete-hasura, undeploy-hasura]
steps:
- name: "Checkout: ${{github.event.pull_request.head.label}}"
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v3
with:
registry: ${{needs.env.outputs.DOCKER_REGISTRY}}
username: _json_key
password: ${{secrets.GCP_SA_KEY}}
- name: "Build & Push Container Image: ${{needs.env.outputs.HASURA_TAG}}"
uses: docker/build-push-action@v5
with:
file: hasura/Dockerfile
context: hasura
tags: ${{needs.env.outputs.HASURA_TAG}}
build-args: |
BACKEND_HOST=${{needs.env.outputs.BACKEND_HOST}}
BACKEND_PROTOCOL=https
push: true
deploy-hasura:
name: Deploy Hasura
runs-on: ubuntu-latest
needs: [env, build-hasura, deploy-backend]
env:
db: ${{needs.env.outputs.DB_NAME}}
pass: ${{needs.env.outputs.DB_PASSWORD}}
host: ${{needs.env.outputs.DB_HOST}}
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Deploy Container Image: ${{needs.env.outputs.HASURA_TAG}}"
run: |
gcloud -q run deploy ${{needs.env.outputs.HASURA_SERVICE}} \
--image ${{needs.env.outputs.HASURA_TAG}} \
--region ${{needs.env.outputs.CLOUDRUN_REGION}} \
--port ${{needs.env.outputs.HASURA_PORT}} \
--cpu 1 \
--memory 512Mi \
--ingress all \
--allow-unauthenticated \
--add-cloudsql-instances ${{needs.env.outputs.CLOUDSQL_CONNECTION_NAME}} \
--max-instances 1 \
--set-env-vars REMOTE_SCHEMA_ENDPOINT=${{needs.env.outputs.REMOTE_SCHEMA_ENDPOINT}} \
--set-env-vars HASURA_GRAPHQL_DATABASE_URL=postgres://${{env.db}}:${{env.pass}}@${{env.host}} \
--set-env-vars HASURA_GRAPHQL_ADMIN_SECRET=${{needs.env.outputs.HASURA_SECRET}} \
--set-env-vars HASURA_GRAPHQL_SERVER_PORT=${{needs.env.outputs.HASURA_PORT}} \
--set-env-vars HASURA_GRAPHQL_ENABLE_CONSOLE=true
undeploy-frontend:
name: Undeploy Frontend
runs-on: ubuntu-latest
needs: [env]
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Delete Service: ${{needs.env.outputs.FRONTEND_SERVICE}}"
continue-on-error: true
run: |
gcloud -q run services delete ${{needs.env.outputs.FRONTEND_SERVICE}} \
--region ${{needs.env.outputs.CLOUDRUN_REGION}}
delete-frontend:
name: Delete Frontend Container Image
runs-on: ubuntu-latest
needs: [env]
steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
- name: "Delete Container Image: ${{needs.env.outputs.FRONTEND_TAG}}"
continue-on-error: true
run: gcloud -q artifacts docker images delete ${{needs.env.outputs.FRONTEND_TAG}}
build-frontend:
name: Build Frontend Container Image
runs-on: ubuntu-latest
needs: [env, delete-frontend, undeploy-frontend, deploy-hasura, seed-db]
steps:
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v3
with:
registry: ${{needs.env.outputs.DOCKER_REGISTRY}}
username: _json_key
password: ${{secrets.GCP_SA_KEY}}
- name: "Build & Push Container Image: ${{needs.env.outputs.FRONTEND_TAG}}"
uses: docker/build-push-action@v5
with:
file: docker/frontend/Dockerfile
tags: ${{needs.env.outputs.FRONTEND_TAG}}
build-args: |
TARGET=${{needs.env.outputs.FRONTEND_TARGET}}
APP_ENV=${{needs.env.outputs.APP_ENV}}
GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}}
FRONTEND_URL=${{needs.env.outputs.FRONTEND_URL}}
YOUTUBE_API_KEY=${{secrets.YOUTUBE_API_KEY}}
IMGIX_TOKEN=${{secrets.IMGIX_TOKEN}}
WEB3_STORAGE_TOKEN=${{secrets.WEB3_STORAGE_TOKEN}}
OPENSEA_API_KEY=${{secrets.OPENSEA_API_KEY}}
GCAL_PRIVATE_KEY=${{secrets.GCAL_PRIVATE_KEY}}
GCAL_PROJECT_NUMBER=${{secrets.GCAL_PROJECT_NUMBER}}
GCAL_CLIENT_EMAIL=${{secrets.GCAL_CLIENT_EMAIL}}
GCAL_CALENDAR_ID=${{secrets.GCAL_CALENDAR_ID}}
WEB3_STORAGE_DID=${{secrets.WEB3_STORAGE_DID}}
WEB3_STORAGE_PROOF=${{secrets.WEB3_STORAGE_PROOF}}
WEB3_STORAGE_KEY=${{secrets.WEB3_STORAGE_KEY}}
ALCHEMY_MAINNET=${{secrets.ALCHEMY_MAINNET}}
ALCHEMY_OPTIMISM=${{secrets.ALCHEMY_OPTIMISM}}
ALCHEMY_POLYGON=${{secrets.ALCHEMY_POLYGON}}
ALCHEMY_API_KEY=${{secrets.ALCHEMY_API_KEY}}
WALLET_CONNECT_V2_KEY=${{secrets.WALLET_CONNECT_V2_KEY}}
push: true
deploy-frontend:
name: Deploy Frontend
runs-on: ubuntu-latest
needs: [env, build-frontend]
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
credentials_json: ${{secrets.GCP_SA_KEY}}
create_credentials_file: true
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]
- name: "Deploy Container Image: ${{needs.env.outputs.FRONTEND_SERVICE}}"
# this is running a shell script of unknown provision that's failing
# the deployment, however, isn't
continue-on-error: true
run: |
gcloud -q run deploy ${{needs.env.outputs.FRONTEND_SERVICE}} \
--image ${{needs.env.outputs.FRONTEND_TAG}} \
--region ${{needs.env.outputs.CLOUDRUN_REGION}} \
--port ${{needs.env.outputs.FRONTEND_PORT}} \
--cpu ${{needs.env.outputs.FRONTEND_TARGET == 'development' && '2' || '1'}} \
--memory ${{needs.env.outputs.FRONTEND_TARGET == 'development' && '5Gi' || '1Gi'}} \
--ingress all \
--max-instances 1 \
--allow-unauthenticated \
--set-env-vars GCAL_PRIVATE_KEY="${{secrets.GCAL_PRIVATE_KEY}}" \
--set-env-vars GCAL_PROJECT_NUMBER="${{secrets.GCAL_PROJECT_NUMBER}}" \
--set-env-vars GCAL_CLIENT_EMAIL="${{secrets.GCAL_CLIENT_EMAIL}}" \
--set-env-vars NEXT_PUBLIC_GCAL_CALENDAR_ID="${{secrets.GCAL_CALENDAR_ID}}" \
--set-env-vars OPENSEA_API_KEY="${{secrets.OPENSEA_API_KEY}}" \
--set-env-vars NEXT_PUBLIC_GOOGLE_ANALYTICS_ID="${{secrets.GOOGLE_ANALYTICS_ID}}" \
--set-env-vars NEXT_PUBLIC_YOUTUBE_API_KEY="${{secrets.YOUTUBE_API_KEY}}" \
--set-env-vars NEXT_PUBLIC_WEB3_STORAGE_DID="${{secrets.WEB3_STORAGE_DID}}" \
--set-env-vars NEXT_PUBLIC_WEB3_STORAGE_PROOF="${{secrets.WEB3_STORAGE_PROOF}}" \
--set-env-vars NEXT_PUBLIC_WEB3_STORAGE_KEY="${{secrets.WEB3_STORAGE_KEY}}" \
--set-env-vars NEXT_PUBLIC_ALCHEMY_MAINNET="${{secrets.ALCHEMY_MAINNET}}" \
--set-env-vars NEXT_PUBLIC_ALCHEMY_OPTIMISM="${{secrets.ALCHEMY_OPTIMISM}}" \
--set-env-vars NEXT_PUBLIC_ALCHEMY_POLYGON="${{secrets.ALCHEMY_POLYGON}}" \
--set-env-vars NEXT_PUBLIC_ALCHEMY_API_KEY="${{secrets.ALCHEMY_API_KEY}}" \
--set-env-vars NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID="${{secrets.WALLET_CONNECT_V2_KEY}}"
seed-db:
name: Seed Database
runs-on: ubuntu-latest
needs: [env, deploy-hasura]
steps:
- name: "Checkout: ${{github.event.pull_request.head.label}}"
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.sha}}
- name: Seed Database
continue-on-error: true
run: |
mv package.json package.json.temp
npm install --no-package-lock --no-save node-fetch bottleneck
mv package.json.temp package.json
SOURCE_GRAPHQL_URL="${{needs.env.outputs.GRAPHQL_URL}}" \
ACCOUNT_SYNC_URL="${{needs.env.outputs.SC_SYNC_URL}}" \
yarn hasura:seed-db
finish-deployment:
name: Finish Deployment
runs-on: ubuntu-latest
needs: [env, start-deployment, deploy-frontend]
if: always()
env:
result: ${{needs.deploy-frontend.result}}
steps:
- name: Finish Deployment
uses: bobheadxi/deployments@v1
with:
step: finish
token: ${{github.token}}
env: ${{env.DEPLOYMENT_NAME}}
env_url: ${{needs.env.outputs.FRONTEND_URL}}
status: ${{env.result == 'skipped' && 'cancelled' || env.result}}
deployment_id: ${{needs.start-deployment.outputs.deployment_id}}