1
1
name : Deploy Workflow
2
2
3
3
on :
4
- workflow_dispatch :
5
4
workflow_call :
6
5
7
6
env :
8
7
PREFIX : " fum"
9
8
SHA : ${{ github.event.pull_request.head.sha || github.sha }}
9
+ KUBE_NAMESPACE : ${{ secrets.KUBE_NAMESPACE }}
10
+ KUBE_CERT : ${{ secrets.KUBE_CERT }}
11
+ KUBE_TOKEN : ${{ secrets.KUBE_TOKEN }}
12
+ KUBE_CLUSTER : ${{ secrets.KUBE_CLUSTER }}
10
13
11
14
concurrency :
12
15
group : deploy-${{ github.ref }}
16
19
build :
17
20
runs-on : ubuntu-latest
18
21
22
+ outputs :
23
+ build_tag : ${{ steps.vars.outputs.build_tag }}
24
+
19
25
permissions :
20
26
id-token : write # This is required for requesting the JWT
21
27
contents : read # This is required for actions/checkout
65
71
id-token : write # This is required for requesting the JWT
66
72
contents : read # This is required for actions/checkout
67
73
68
- env :
69
- KUBE_NAMESPACE : ${{ secrets.KUBE_NAMESPACE }}
70
-
71
74
steps :
72
75
- name : Checkout
73
76
uses : actions/checkout@v4
82
85
uses : aws-actions/amazon-ecr-login@v2
83
86
id : login-ec
84
87
85
- - name : Store build tag
86
- id : vars
87
- run : |
88
- branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
89
- short_sha=$(git rev-parse --short $SHA)
90
- build_tag=$PREFIX-$branch-$short_sha
91
- echo "build_tag=$build_tag" >> $GITHUB_OUTPUT
92
-
93
88
- name : Update image tag
94
89
env :
95
90
ECR_URL : ${{ vars.ECR_URL }}
@@ -105,10 +100,6 @@ jobs:
105
100
docker push ${{ vars.ECR_URL }}:staging.latest
106
101
107
102
- name : Authenticate to the cluster
108
- env :
109
- KUBE_CERT : ${{ secrets.KUBE_CERT }}
110
- KUBE_TOKEN : ${{ secrets.KUBE_TOKEN }}
111
- KUBE_CLUSTER : ${{ secrets.KUBE_CLUSTER }}
112
103
run : |
113
104
echo "${KUBE_CERT}" > ca.crt
114
105
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
@@ -120,35 +111,14 @@ jobs:
120
111
run : |
121
112
kubectl -n ${KUBE_NAMESPACE} apply -f config/kubernetes/staging
122
113
123
- - name : Send deploy notification to product Slack channel
124
- uses : slackapi/slack-github-action@v1.27.0
125
- with :
126
- payload : |
127
- {
128
- "attachments": [
129
- {
130
- "color": "#1d990c",
131
- "text": "${{ github.actor }} deployed *${{ steps.vars.outputs.build_tag }}* to *Staging*",
132
- "fields": [
133
- {
134
- "title": "Project",
135
- "value": "Find Unclaimed Court Money",
136
- "short": true
137
- }
138
- ],
139
- "actions": [
140
- {
141
- "text": "Visit Job",
142
- "type": "button",
143
- "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
144
- }
145
- ]
146
- }
147
- ]
148
- }
149
- env :
150
- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
151
- SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
114
+ notify-staging :
115
+ needs : [build, deploy-staging]
116
+ uses : ./.github/workflows/notification.yml
117
+ secrets :
118
+ webhook_url : ${{ secrets.SLACK_WEBHOOK_URL }}
119
+ with :
120
+ build_tag : ${{ needs.build.outputs.build_tag }}
121
+ environment : Staging
152
122
153
123
deploy-production :
154
124
runs-on : ubuntu-latest
@@ -160,9 +130,6 @@ jobs:
160
130
id-token : write # This is required for requesting the JWT
161
131
contents : read # This is required for actions/checkout
162
132
163
- env :
164
- KUBE_NAMESPACE : ${{ secrets.KUBE_NAMESPACE }}
165
-
166
133
steps :
167
134
- name : Checkout
168
135
uses : actions/checkout@v4
@@ -177,14 +144,6 @@ jobs:
177
144
uses : aws-actions/amazon-ecr-login@v2
178
145
id : login-ecr
179
146
180
- - name : Store build tag
181
- id : vars
182
- run : |
183
- branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
184
- short_sha=$(git rev-parse --short $SHA)
185
- build_tag=$PREFIX-$branch-$short_sha
186
- echo "build_tag=$build_tag" >> $GITHUB_OUTPUT
187
-
188
147
- name : Update image tag
189
148
env :
190
149
ECR_URL : ${{ vars.ECR_URL }}
@@ -200,10 +159,6 @@ jobs:
200
159
docker push ${{ vars.ECR_URL }}:production.latest
201
160
202
161
- name : Authenticate to the cluster
203
- env :
204
- KUBE_CERT : ${{ secrets.KUBE_CERT }}
205
- KUBE_TOKEN : ${{ secrets.KUBE_TOKEN }}
206
- KUBE_CLUSTER : ${{ secrets.KUBE_CLUSTER }}
207
162
run : |
208
163
echo "${KUBE_CERT}" > ca.crt
209
164
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
@@ -215,62 +170,20 @@ jobs:
215
170
run : |
216
171
kubectl -n ${KUBE_NAMESPACE} apply -f config/kubernetes/production
217
172
218
- - name : Send deploy notification to product Slack channel
219
- uses : slackapi/slack-github-action@v1.27.0
220
- with :
221
- payload : |
222
- {
223
- "attachments": [
224
- {
225
- "color": "#1d990c",
226
- "text": "${{ github.actor }} deployed *${{ steps.vars.outputs.build_tag }}* to *Production*",
227
- "fields": [
228
- {
229
- "title": "Project",
230
- "value": "Find Unclaimed Court Money",
231
- "short": true
232
- }
233
- ],
234
- "actions": [
235
- {
236
- "text": "Visit Job",
237
- "type": "button",
238
- "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
239
- }
240
- ]
241
- }
242
- ]
243
- }
244
- env :
245
- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
246
- SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
247
-
248
- - name : Send deploy notification to product Slack channel
249
- uses : slackapi/slack-github-action@v1.27.0
250
- with :
251
- payload : |
252
- {
253
- "attachments": [
254
- {
255
- "color": "#1d990c",
256
- "text": "${{ github.actor }} deployed *${{ steps.vars.outputs.build_tag }}* to *Production*",
257
- "fields": [
258
- {
259
- "title": "Project",
260
- "value": "Find Unclaimed Court Money",
261
- "short": true
262
- }
263
- ],
264
- "actions": [
265
- {
266
- "text": "Visit Job",
267
- "type": "button",
268
- "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
269
- }
270
- ]
271
- }
272
- ]
273
- }
274
- env :
275
- SLACK_WEBHOOK_URL : ${{ secrets.PROD_SLACK_WEBHOOK_URL }}
276
- SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
173
+ notify-production :
174
+ needs : [build, deploy-production]
175
+ uses : ./.github/workflows/notification.yml
176
+ secrets :
177
+ webhook_url : ${{ secrets.SLACK_WEBHOOK_URL }}
178
+ with :
179
+ build_tag : ${{ needs.build.outputs.build_tag }}
180
+ environment : Production
181
+
182
+ notify-production-2 :
183
+ needs : [build, deploy-production]
184
+ uses : ./.github/workflows/notification.yml
185
+ secrets :
186
+ webhook_url : ${{ secrets.PROD_SLACK_WEBHOOK_URL }}
187
+ with :
188
+ build_tag : ${{ needs.build.outputs.build_tag }}
189
+ environment : Production
0 commit comments