forked from target/strelka
-
Notifications
You must be signed in to change notification settings - Fork 1
272 lines (243 loc) · 10.5 KB
/
tag-latest.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
261
262
263
264
265
266
267
268
269
270
271
272
name: Finalize Tags
# Workflow this will update various mutable tags to match the full semver given in the input tag.
# E.g. if an image is tagged 0.1.2 and this workflow is triggered with a tag `latest-v0.1.2` then it will update tags:
# latest, 0, and 0.1 to point to the 0.1.2 image.
on:
create:
jobs:
update_latest_tag:
name: Build & Push to Registries
if: ${{ startsWith(github.ref, 'refs/tags/latest-v') }}
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/[email protected]
continue-on-error: true
with:
role-to-assume: ${{ secrets.ECR_REPO_ROLE }}
role-duration-seconds: 7200 # 2 hours
aws-region: us-east-1
- name: 2nd Attempt Configure AWS credentials
uses: aws-actions/[email protected]
if: ${{ env.AWS_ACCESS_KEY_ID == '' }}
with:
role-to-assume: ${{ secrets.ECR_REPO_ROLE }}
role-duration-seconds: 7200 # 2 hours
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Configure AWS credentials (Gov Cloud)
uses: aws-actions/[email protected]
continue-on-error: true
id: login-aws-gov-cloud
with:
output-credentials: true
unset-current-credentials: true
role-to-assume: ${{ secrets.ECR_GOV_CLOUD_REPO_ROLE }}
role-duration-seconds: 7200 # 2 hours
aws-region: us-gov-west-1
- name: 2nd Attempt Configure AWS credentials (Gov Cloud)
uses: aws-actions/[email protected]
if: ${{ steps.login-aws-gov-cloud.outputs.aws-access-key-id == '' }}
with:
unset-current-credentials: true
role-to-assume: ${{ secrets.ECR_GOV_CLOUD_REPO_ROLE }}
role-duration-seconds: 7200 # 2 hours
aws-region: us-gov-west-1
- name: Login to Amazon ECR (GovCloud)
id: login-ecr-gov-cloud
uses: aws-actions/amazon-ecr-login@v1
- name: Validate ECR Repos
run: |
# If something is wrong with the GovCloud login the GovCloud ECR login will succeed using the standard creds
# Make sure we have two different ECR repos to make this clear.
if [[ ${{ steps.login-ecr.outputs.registry }} = ${{ steps.login-ecr-gov-cloud.outputs.registry }} ]]; then
exit 1
fi
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# If this workflow runs for a semver that hasn't been released, then we'll fail below. This workflow is only
# meant to add the `latest` tag onto an existing release.
- name: Determine the version from the tag
id: get_ver
run: |
SEM_VER=$(echo "${{ github.ref }}" | grep -E -o "[0-9]+\.[0-9]+.[0-9]*")
if [ -z $SEM_VER ]; then
exit 1
fi
echo "::set-output name=SEM_VER::$SEM_VER"
MAJOR_VERSION=$(echo "$SEM_VER" | grep -E -o "^[0-9]+")
echo "::set-output name=MAJOR_VERSION::$MAJOR_VERSION"
MINOR_VERSION=$(echo "$SEM_VER" | grep -E -o "^[0-9]+\.[0-9]+")
echo "::set-output name=MINOR_VERSION::$MINOR_VERSION"
# Right now just pull the image in order to tag it. There might be alternatives:
# https://stackoverflow.com/questions/37134929/how-to-tag-image-in-docker-registry-v2/38362476#38362476 (auth unclear)
# Use a shared context with original workflow?
- name: Pull, Tag, Push FrontEnd
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_GC_REGISTRY: ${{ steps.login-ecr-gov-cloud.outputs.registry }}
SEM_VER: ${{ steps.get_ver.outputs.SEM_VER }}
MAJOR_VERSION: ${{ steps.get_ver.outputs.MAJOR_VERSION }}
MINOR_VERSION: ${{ steps.get_ver.outputs.MINOR_VERSION }}
run: |
amd_tag=amd64-$SEM_VER
arm_tag=arm64-$SEM_VER
docker_hub=sublimesec/strelka-frontend
ecr=$ECR_REGISTRY/strelka-frontend
ecr_gc=$ECR_GC_REGISTRY/strelka-frontend
docker manifest create $docker_hub:latest \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:latest \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:latest \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest create $docker_hub:$MAJOR_VERSION \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:$MAJOR_VERSION \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:$MAJOR_VERSION \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest create $docker_hub:$MINOR_VERSION \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:$MINOR_VERSION \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:$MINOR_VERSION \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest push $docker_hub:latest
docker manifest push $ecr:latest
docker manifest push $ecr_gc:latest
docker manifest push $docker_hub:$MAJOR_VERSION
docker manifest push $ecr:$MAJOR_VERSION
docker manifest push $ecr_gc:$MAJOR_VERSION
docker manifest push $docker_hub:$MINOR_VERSION
docker manifest push $ecr:$MINOR_VERSION
docker manifest push $ecr_gc:$MAJOR_VERSION
- name: Pull, Tag, Push BackEnd
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_GC_REGISTRY: ${{ steps.login-ecr-gov-cloud.outputs.registry }}
SEM_VER: ${{ steps.get_ver.outputs.SEM_VER }}
MAJOR_VERSION: ${{ steps.get_ver.outputs.MAJOR_VERSION }}
MINOR_VERSION: ${{ steps.get_ver.outputs.MINOR_VERSION }}
run: |
amd_tag=amd64-$SEM_VER
arm_tag=arm64-$SEM_VER
docker_hub=sublimesec/strelka-backend
ecr=$ECR_REGISTRY/strelka-backend
ecr_gc=$ECR_GC_REGISTRY/strelka-backend
docker manifest create $docker_hub:latest \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:latest \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:latest \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest create $docker_hub:$MAJOR_VERSION \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:$MAJOR_VERSION \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:$MAJOR_VERSION \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest create $docker_hub:$MINOR_VERSION \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:$MINOR_VERSION \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:$MINOR_VERSION \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest push $docker_hub:latest
docker manifest push $ecr:latest
docker manifest push $ecr_gc:latest
docker manifest push $docker_hub:$MAJOR_VERSION
docker manifest push $ecr:$MAJOR_VERSION
docker manifest push $ecr_gc:$MAJOR_VERSION
docker manifest push $docker_hub:$MINOR_VERSION
docker manifest push $ecr:$MINOR_VERSION
docker manifest push $ecr_gc:$MAJOR_VERSION
- name: Pull, Tag, Push Manager
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_GC_REGISTRY: ${{ steps.login-ecr-gov-cloud.outputs.registry }}
SEM_VER: ${{ steps.get_ver.outputs.SEM_VER }}
MAJOR_VERSION: ${{ steps.get_ver.outputs.MAJOR_VERSION }}
MINOR_VERSION: ${{ steps.get_ver.outputs.MINOR_VERSION }}
run: |
amd_tag=amd64-$SEM_VER
arm_tag=arm64-$SEM_VER
docker_hub=sublimesec/strelka-manager
ecr=$ECR_REGISTRY/strelka-manager
ecr_gc=$ECR_GC_REGISTRY/strelka-manager
docker manifest create $docker_hub:latest \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:latest \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:latest \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest create $docker_hub:$MAJOR_VERSION \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:$MAJOR_VERSION \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:$MAJOR_VERSION \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest create $docker_hub:$MINOR_VERSION \
$docker_hub:$amd_tag \
$docker_hub:$arm_tag
docker manifest create $ecr:$MINOR_VERSION \
$ecr:$amd_tag \
$ecr:$arm_tag
docker manifest create $ecr_gc:$MINOR_VERSION \
$ecr_gc:$amd_tag \
$ecr_gc:$arm_tag
docker manifest push $docker_hub:latest
docker manifest push $ecr:latest
docker manifest push $ecr_gc:latest
docker manifest push $docker_hub:$MAJOR_VERSION
docker manifest push $ecr:$MAJOR_VERSION
docker manifest push $ecr_gc:$MAJOR_VERSION
docker manifest push $docker_hub:$MINOR_VERSION
docker manifest push $ecr:$MINOR_VERSION
docker manifest push $ecr_gc:$MAJOR_VERSION
- name: Validate All X-Region Replication
run: |
.github/workflows/check_images_x_region.sh latest
if [ $? != 0 ]; then
exit 1
fi
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_Z_LOG_DOCKER_BUILDS }}
SLACK_TITLE: Strelka Images latest tag updated to ${{ steps.get_ver.outputs.SEM_VER }}