forked from target/strelka
-
Notifications
You must be signed in to change notification settings - Fork 1
197 lines (173 loc) · 7.34 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
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 DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# 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 }}
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
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 $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 $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 push $docker_hub:latest
docker manifest push $ecr:latest
docker manifest push $docker_hub:$MAJOR_VERSION
docker manifest push $ecr:$MAJOR_VERSION
docker manifest push $docker_hub:$MINOR_VERSION
docker manifest push $ecr:$MINOR_VERSION
- name: Pull, Tag, Push BackEnd
env:
ECR_REGISTRY: ${{ steps.login-ecr.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
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 $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 $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 push $docker_hub:latest
docker manifest push $ecr:latest
docker manifest push $docker_hub:$MAJOR_VERSION
docker manifest push $ecr:$MAJOR_VERSION
docker manifest push $docker_hub:$MINOR_VERSION
docker manifest push $ecr:$MINOR_VERSION
- name: Pull, Tag, Push Manager
env:
ECR_REGISTRY: ${{ steps.login-ecr.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
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 $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 $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 push $docker_hub:latest
docker manifest push $ecr:latest
docker manifest push $docker_hub:$MAJOR_VERSION
docker manifest push $ecr:$MAJOR_VERSION
docker manifest push $docker_hub:$MINOR_VERSION
docker manifest push $ecr:$MINOR_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 }}