-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (195 loc) · 7.3 KB
/
example-build-deploy-dockerfile-google.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
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
name: Build and deploy to Atlas with Dockerfile on Google Cloud
on:
push:
branches: [trunk]
## Adding a path filter will only trigger the workflow if the files in the path are modified.
## This is very useful if you have a monorepo structure.
## See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore for more information.
##
# paths:
# - 'applications/my-app/**'
##
# pull_request:
# branches: [trunk]
env:
SYSTEM_NAME: 'core'
APPLICATION_NAME: 'demo-api-go'
PROJECT_FILE: 'applications/demo-api-go/Dockerfile'
HELM_VALUES_FILE: '.github/deploy/values-demo-api-go.yml'
jobs:
build-scan:
name: Build and Scan
runs-on: elvia-runner
permissions:
actions: read
contents: write
id-token: write
pull-requests: write
security-events: write
# Limits the number of concurrent runs of this job to one, and cancels any in progress.
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}-build-scan'
cancel-in-progress: true
environment: build
steps:
# START REMOVE FROM EXAMPLE
- name: Get GitHub App token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
owner: ${{ github.repository_owner }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
repositories: 'core'
- name: Checkout core repository
uses: actions/checkout@v4
with:
repository: '3lvia/core'
token: ${{ steps.app-token.outputs.token }}
# END REMOVE FROM EXAMPLE
- uses: 3lvia/core-github-actions-templates/build@trunk
with:
name: ${{ env.APPLICATION_NAME }}
namespace: ${{ env.SYSTEM_NAME }}
project-file: ${{ env.PROJECT_FILE }}
trivy-upload-report: 'false'
trivy-post-comment: 'true'
AZURE_CLIENT_ID: ${{ vars.ACR_CLIENT_ID }}
# START REMOVE FROM EXAMPLE
checkout: 'false'
# END REMOVE FROM EXAMPLE
deploy-dev:
name: Deploy Dev
# Require all jobs below to be successful before running this job.
# Any of these can be commented out or removed if you want to deploy anyway.
needs:
- build-scan
runs-on: elvia-runner
permissions:
contents: read
id-token: write
# Limits the number of concurrent runs of this job to one, and cancels any in progress.
concurrency:
group: 'dev-google--this-group-is-replaced-in-final-example-needs-this-to-not-deploy-demo-api-go-simultaneously-in-two-examples'
environment: dev
steps:
# START REMOVE FROM EXAMPLE
- name: Get GitHub App token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
owner: ${{ github.repository_owner }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
repositories: 'core'
- name: Checkout core repository
uses: actions/checkout@v4
with:
repository: '3lvia/core'
token: ${{ steps.app-token.outputs.token }}
# END REMOVE FROM EXAMPLE
- uses: 3lvia/core-github-actions-templates/deploy@trunk
with:
name: ${{ env.APPLICATION_NAME }}
namespace: ${{ env.SYSTEM_NAME }}
environment: 'dev'
helm-values-file: ${{ env.HELM_VALUES_FILE }}
runtime-cloud-provider: 'GKE'
# Will post to the Slack channel of your system if the deployment fails.
# Can be commented out if you don't want this.
slack-channel: '#team-${{ env.SYSTEM_NAME }}-alerts'
GC_SERVICE_ACCOUNT: ${{ vars.GC_SERVICE_ACCOUNT }}
GC_WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GC_WORKLOAD_IDENTITY_PROVIDER }}
# START REMOVE FROM EXAMPLE
checkout: 'false'
# END REMOVE FROM EXAMPLE
deploy-test:
name: Deploy Test
# Only deploy to test after dev
needs: [deploy-dev]
runs-on: elvia-runner
permissions:
contents: read
id-token: write
# Limits the number of concurrent runs of this job to one, and cancels any in progress.
concurrency:
group: 'test-google--this-group-is-replaced-in-final-example-needs-this-to-not-deploy-demo-api-go-simultaneously-in-two-examples'
environment: test
# Only on push to trunk
if: github.ref == 'refs/heads/trunk'
steps:
# START REMOVE FROM EXAMPLE
- name: Get GitHub App token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
owner: ${{ github.repository_owner }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
repositories: 'core'
- name: Checkout core repository
uses: actions/checkout@v4
with:
repository: '3lvia/core'
token: ${{ steps.app-token.outputs.token }}
# END REMOVE FROM EXAMPLE
- uses: 3lvia/core-github-actions-templates/deploy@trunk
with:
name: ${{ env.APPLICATION_NAME }}
namespace: ${{ env.SYSTEM_NAME }}
environment: 'test'
helm-values-file: ${{ env.HELM_VALUES_FILE }}
runtime-cloud-provider: 'GKE'
# Will post to the Slack channel of your system if the deployment fails.
# Can be commented out if you don't want this.
slack-channel: '#team-${{ env.SYSTEM_NAME }}-alerts'
GC_SERVICE_ACCOUNT: ${{ vars.GC_SERVICE_ACCOUNT }}
GC_WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GC_WORKLOAD_IDENTITY_PROVIDER }}
# START REMOVE FROM EXAMPLE
checkout: 'false'
# END REMOVE FROM EXAMPLE
deploy-prod:
name: Deploy Prod
# Only deploy to prod after test
needs: [deploy-test]
runs-on: elvia-runner
permissions:
contents: read
id-token: write
# Limits the number of concurrent runs of this job to one, and cancels any in progress.
concurrency:
group: 'prod-google--this-group-is-replaced-in-final-example-needs-this-to-not-deploy-demo-api-go-simultaneously-in-two-examples'
environment: prod
# Only on push to trunk
if: github.ref == 'refs/heads/trunk'
steps:
# START REMOVE FROM EXAMPLE
- name: Get GitHub App token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
owner: ${{ github.repository_owner }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
repositories: 'core'
- name: Checkout core repository
uses: actions/checkout@v4
with:
repository: '3lvia/core'
token: ${{ steps.app-token.outputs.token }}
# END REMOVE FROM EXAMPLE
- uses: 3lvia/core-github-actions-templates/deploy@trunk
with:
name: ${{ env.APPLICATION_NAME }}
namespace: ${{ env.SYSTEM_NAME }}
environment: 'prod'
helm-values-file: ${{ env.HELM_VALUES_FILE }}
runtime-cloud-provider: 'GKE'
# Will post to the Slack channel of your system if the deployment fails.
# Can be commented out if you don't want this.
slack-channel: '#team-${{ env.SYSTEM_NAME }}-alerts'
GC_SERVICE_ACCOUNT: ${{ vars.GC_SERVICE_ACCOUNT }}
GC_WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GC_WORKLOAD_IDENTITY_PROVIDER }}
# START REMOVE FROM EXAMPLE
checkout: 'false'
# END REMOVE FROM EXAMPLE