-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (83 loc) · 2.7 KB
/
deploy-app.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
name: deploy-app
on:
workflow_call:
inputs:
env:
required: true
type: string
GCP_PROJECT_ID:
required: true
type: string
GCP_WORKLOAD_IDENTITY_PROVIDER:
required: true
type: string
GCP_SERVICE_ACCOUNT:
required: true
type: string
APP_ID_GITHUB:
required: true
type: string
PR_AUTHOR:
required: true
type: string
PROJECT_NUMBER:
required: true
type: string
COLUMN_NAME:
required: true
type: string
webhook_path:
required: true
type: string
secrets:
gcp_webhook_secret:
required: true
gcp_app_key:
required: true
jobs:
deploy:
name: Setup Gcloud Account
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
env:
gcp_service_region: us-central1
steps:
- name: Deploy New App Version
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: 'Authenticate with GCP'
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ inputs.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ inputs.GCP_SERVICE_ACCOUNT }}
- name: 'Set up Cloud SDK'
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ inputs.GCP_PROJECT_ID }}
- name: Update secrets in GCP Secret Manager
uses: nearform-actions/github-action-gcp-secrets@v1
with:
secrets: |-
unbreak_${{ inputs.env }}_webhook_secret:"${{ secrets.GCP_WEBHOOK_SECRET }}"
unbreak_${{ inputs.env }}_app_key:"${{ secrets.GCP_APP_KEY }}"
- name: 'Deploy webhook to Cloud Run'
id: deploy-webhook
run: >-
gcloud functions deploy ${{ inputs.webhook_path }}
--runtime=nodejs20
--source=.
--entry-point=webhook
--set-secrets=APP_KEY=projects/${{ inputs.GCP_PROJECT_ID }}/secrets/unbreak_${{ inputs.env }}_app_key:latest
--set-secrets=WEBHOOK_SECRET=projects/${{ inputs.GCP_PROJECT_ID }}/secrets/unbreak_${{ inputs.env }}_webhook_secret:latest
--set-env-vars=APP_ID="${{ inputs.APP_ID_GITHUB }}"
--set-env-vars=PR_AUTHOR="${{ inputs.PR_AUTHOR }}"
--set-env-vars=PROJECT_NUMBER="${{ inputs.PROJECT_NUMBER }}"
--set-env-vars=COLUMN_NAME="${{ inputs.COLUMN_NAME }}"
--set-env-vars=LOG_LEVEL=info
--trigger-http
--allow-unauthenticated
--region=us-central1
--gen2