-
Notifications
You must be signed in to change notification settings - Fork 1
172 lines (159 loc) Β· 6.17 KB
/
push.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
172
name: Push Events
on:
push:
branches:
- main
- dev
permissions:
contents: write
id-token: write
deployments: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MEMORY: 4G
TIMEOUT: 20m
TRIGGER_PARAMS: |
--location=nam5 \
--destination-run-service=download \
--destination-run-region=us-central1 \
--destination-run-path="/process_job" \
--event-data-content-type="application/protobuf" \
--event-filters="database=(default)" \
--event-filters-path-pattern="document=**/*-input" \
--event-filters="type=google.cloud.firestore.document.v1.created"
jobs:
release-please:
name: Create release
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
steps:
- name: π Create Release
id: release-please
uses: agrc/release-composite-action@v1
with:
prerelease: ${{ github.ref_name == 'dev' }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
github-app-id: ${{ secrets.UGRC_RELEASE_BOT_APP_ID }}
github-app-key: ${{ secrets.UGRC_RELEASE_BOT_APP_KEY }}
github-app-name: ${{ secrets.UGRC_RELEASE_BOT_NAME }}
github-app-email: ${{ secrets.UGRC_RELEASE_BOT_EMAIL }}
deploy-dev:
name: Deploy to dev
runs-on: ubuntu-latest
needs: release-please
environment:
name: dev
url: https://enviro.dev.utah.gov
if: github.ref_name == 'dev' && needs.release-please.outputs.release_created
steps:
- name: π Deploy Firebase
uses: agrc/firebase-website-deploy-composite-action@v1
with:
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
prebuild-command: |
cd functions
npm ci
cd ..
build-command: npm run build:stage
env:
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
VITE_DISCOVER_KEY: ${{ secrets.DISCOVER_KEY }}
VITE_WEB_API_KEY: ${{ secrets.WEB_API_KEY }}
VITE_DOWNLOAD_URL: ${{ secrets.DOWNLOAD_URL }}
NODE_OPTIONS: --max-old-space-size=7168
- name: π Deploy Cloud Run
uses: agrc/cloud-run-docker-deploy-composite-action@v2
with:
docker-context: ./cloudrun
docker-file: ./cloudrun/Dockerfile
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
service: download
flags: |
--service-account=cloud-run-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com
--max-instances=10
--min-instances=0
--allow-unauthenticated
--memory=${{ env.MEMORY }}
--timeout=${{ env.TIMEOUT }}
--concurrency=1
env-vars: |
BUCKET=${{ secrets.PROJECT_ID }}-downloads
- name: β‘ Create/Update Eventarc Trigger
run: |
if [ ! "$(gcloud eventarc triggers list | grep download)" ]; then
gcloud eventarc triggers create download \
--service-account=${{ secrets.PROJECT_NUMBER }}-compute@developer.gserviceaccount.com \
${{ env.TRIGGER_PARAMS }}
else
gcloud eventarc triggers update download \
--service-account=${{ secrets.PROJECT_NUMBER }}-compute@developer.gserviceaccount.com \
${{ env.TRIGGER_PARAMS }}
fi
deploy-prod:
name: Deploy to production
runs-on: ubuntu-latest
needs: release-please
environment:
name: prod
url: https://enviro.deq.utah.gov
if: github.ref_name == 'main' && needs.release-please.outputs.release_created
steps:
- name: π Deploy Firebase
uses: agrc/firebase-website-deploy-composite-action@v1
with:
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
service-now-instance: ${{ secrets.SN_INSTANCE }}
service-now-table: ${{ secrets.SN_TABLE }}
service-now-system-id: ${{ secrets.SN_SYS_ID }}
service-now-username: ${{ secrets.SN_USERNAME }}
service-now-password: ${{ secrets.SN_PASSWORD }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
prebuild-command: |
cd functions
npm ci
cd ..
build-command: npm run build:prod
env:
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
VITE_DISCOVER_KEY: ${{ secrets.DISCOVER_KEY }}
VITE_WEB_API_KEY: ${{ secrets.WEB_API_KEY }}
VITE_DOWNLOAD_URL: ${{ secrets.DOWNLOAD_URL }}
- name: π Deploy Cloud Run
uses: agrc/cloud-run-docker-deploy-composite-action@v2
with:
docker-context: ./cloudrun
docker-file: ./cloudrun/Dockerfile
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
service: download
flags: |
--service-account=cloud-run-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com
--max-instances=10
--min-instances=0
--allow-unauthenticated
--memory=${{ env.MEMORY }}
--timeout=${{ env.TIMEOUT }}
--concurrency=1
env-vars: |
BUCKET=${{ secrets.PROJECT_ID }}-downloads
- name: β‘ Create/Update Eventarc Trigger
run: |
if [ ! "$(gcloud eventarc triggers list | grep download)" ]; then
gcloud eventarc triggers create download \
--service-account=${{ secrets.PROJECT_NUMBER }}-compute@developer.gserviceaccount.com \
${{ env.TRIGGER_PARAMS }}
else
gcloud eventarc triggers update download \
--service-account=${{ secrets.PROJECT_NUMBER }}-compute@developer.gserviceaccount.com \
${{ env.TRIGGER_PARAMS }}