-
Notifications
You must be signed in to change notification settings - Fork 0
260 lines (212 loc) · 9.28 KB
/
production.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
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
name: 02-auto-deploy
on:
push:
branches:
- master
- release/*
- stage
workflow_dispatch:
inputs:
project_id:
type: choice
description: 'Project ID to deploy'
required: true
default: 'uc-next'
options:
- uc-next
- springbuilder-x
env:
PROJECT_ID: ${{ github.event.inputs.project_id || 'uc-next' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
ENVIRONMENT: "live"
BUILD: ${{ vars.BUILD }}
jobs:
setup_job:
runs-on: ubuntu-latest
outputs:
service_name: ${{ steps.set_output.outputs.service_name }}
timeout_minutes: ${{ steps.set_output.outputs.TIMEOUT_MINUTES }}
deploy_live: ${{ steps.set_output.outputs.deploy_live }}
deploy_stage: ${{ steps.set_output.outputs.deploy_stage }}
deploy_local: ${{ steps.set_output.outputs.deploy_local }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: 'Get External'
run: 'make get-external INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }}'
- name: Set output
id: set_output
run: |
make export-output-github
TIMEOUT_MINUTES=$(( ${{ vars.APPROVAL_TIMEOUT_MINUTES_LIVE }} + 0 ))
echo "Converted number: $TIMEOUT_MINUTES"
echo "TIMEOUT_MINUTES=$TIMEOUT_MINUTES" >> $GITHUB_OUTPUT
build_push_deploy_stage:
runs-on: ubuntu-latest
needs: setup_job
if: ${{ github.ref_name == vars.RELEASE_VERSION && (vars.AUTOMATED_STAGE == 'on' && needs.setup_job.outputs.deploy_stage == 'true') }}
env:
ENVIRONMENT: "stage"
SERVICE_NAME: ${{ needs.setup_job.outputs.service_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ vars.RELEASE_VERSION }}
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'
- name: 'Get External'
run: 'make get-external INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }}'
- name: 'configure Docker & Cluster'
run: 'make auth ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Test 1'
run: 'make test1'
- name: 'Make build push ${{ env.SERVICE_NAME }} for ${{ env.ENVIRONMENT }}'
run: 'make build_github ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }}'
- name: Install Helm
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: simenandre/setup-gke-gcloud-auth-plugin@v1
- name: Download helm value
run: 'make download INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }} ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Deploy ${{ env.SERVICE_NAME }} to ${{ env.ENVIRONMENT }}'
run: 'make deploy HELM=${{ vars.HELM_VERSION }} ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Test 2'
run: 'make test2'
build_push_deploy_local:
runs-on: ubuntu-latest
needs: setup_job
if: ${{ github.ref_name == vars.FROM_BRANCH && needs.setup_job.outputs.deploy_local == 'true' }}
env:
ENVIRONMENT: "local"
SERVICE_NAME: ${{ needs.setup_job.outputs.service_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'
- name: 'Get External'
run: 'make get-external INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }}'
- name: 'configure Docker & Cluster'
run: 'make auth ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Test 1'
run: 'make test1'
- name: 'Make build push ${{ env.SERVICE_NAME }} for ${{ env.ENVIRONMENT }}'
run: 'make build_github ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }}'
- name: Install Helm
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: simenandre/setup-gke-gcloud-auth-plugin@v1
- name: Download helm value
run: 'make download INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }} ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Deploy ${{ env.SERVICE_NAME }} to ${{ env.ENVIRONMENT }}'
run: 'make deploy HELM=${{ vars.HELM_VERSION }} ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Test 2'
run: 'make test2'
build_push_live:
runs-on: ubuntu-latest
needs: setup_job
if: ${{ github.ref_name == vars.FROM_BRANCH && (vars.AUTOMATED_LIVE == 'on' && needs.setup_job.outputs.deploy_live == 'true') }}
env:
SERVICE_NAME: ${{ needs.setup_job.outputs.service_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'
- name: 'Get External'
run: 'make get-external INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }}'
- name: 'configure Docker & Cluster'
run: 'make auth ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Test 1'
run: 'make test1'
- name: 'Make build push ${{ env.SERVICE_NAME }} for ${{ env.ENVIRONMENT }}'
run: 'make build_github ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: 'Test 2'
run: 'make test2'
approval:
runs-on: ubuntu-latest
needs: [setup_job, build_push_live]
env:
SERVICE_NAME: ${{ needs.setup_job.outputs.service_name }}
steps:
- name: send approval
uses: kubmeta/slack-approval@main
env:
SLACK_APP_TOKEN: ${{ secrets.SLACK_APP_TOKEN_LIVE }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_LIVE }}
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET_LIVE }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID_LIVE }}
PROJECT_ID: ${{ env.PROJECT_ID }}
ENVIRONMENT: ${{ env.ENVIRONMENT }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}
timeout-minutes: 3
deploy-to-live:
runs-on: ubuntu-latest
needs: [setup_job, approval]
env:
SERVICE_NAME: ${{ needs.setup_job.outputs.service_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'
- name: 'Get External'
run: 'make get-external INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }}'
- name: 'configure Docker & Cluster'
run: 'make auth ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- name: Install Helm
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download helm value
run: 'make download INFRASTRUCTURE_TOKEN=${{ secrets.INFRASTRUCTURE_TOKEN }} ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
- uses: simenandre/setup-gke-gcloud-auth-plugin@v1
- name: 'Deploy ${{ env.SERVICE_NAME }} to ${{ env.ENVIRONMENT }}'
run: 'make deploy HELM=${{ vars.HELM_VERSION }} ENVIRONMENT=$ENVIRONMENT SERVICE=${{ env.SERVICE_NAME }} PROJECT_ID=$PROJECT_ID'
# - name: Clear CF cache
# run: make clear_cache CLOUDFLARE_TOKEN=${{ secrets.CLOUDFLARE_TOKEN }}
pandayoplus-notification-job-end:
needs: [setup_job, deploy-to-live]
runs-on: ubuntu-latest
env:
SERVICE_NAME: ${{ needs.setup_job.outputs.service_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: kubmeta/slack@pandayoplus
with:
webhook-url: ${{ secrets.CHANNEL_CI_REPORTING_PANDAYOPLUS_WEBHOOK_URL }}
status: ${{ needs.deploy-to-live.result }}
message: "`${{ github.ref_name }}` branch deployment to Project ID ${{ env.PROJECT_ID}} and ENVIRONMENT live of ${{ env.SERVICE_NAME }} service."
if: ${{ !cancelled() && github.ref_name == vars.FROM_BRANCH && needs.deploy-to-live.result != 'skipped' && needs.deploy-to-live.result != 'cancelled' }}
pandayoplus-notification-job-end-stage:
needs: [setup_job, build_push_deploy_stage]
runs-on: ubuntu-latest
env:
SERVICE_NAME: ${{ needs.setup_job.outputs.service_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: kubmeta/slack@pandayoplus
with:
webhook-url: ${{ secrets.CHANNEL_CI_REPORTING_PANDAYOPLUS_WEBHOOK_URL }}
status: ${{ needs.build_push_deploy_stage.result }}
message: "`${{ github.ref_name }}` branch deployment to Project ID ${{ env.PROJECT_ID}} and ENVIRONMENT stage of ${{ env.SERVICE_NAME }} service."
if: ${{ !cancelled() && github.ref_name == vars.RELEASE_VERSION && needs.build_push_deploy_stage.result != 'skipped' && needs.build_push_deploy_stage.result != 'cancelled' }}