-
Notifications
You must be signed in to change notification settings - Fork 42
413 lines (334 loc) · 14.8 KB
/
jobs.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
name: "Release"
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request_target:
types: [labeled]
branches:
- main
- mirror-registry-*
# Allows us to run release manually from the Actions tab
workflow_dispatch:
inputs:
version:
description: 'Version to release (tag name)'
required: true
concurrency:
group: limit-to-one
jobs:
build-install-zip:
name: "Build Installer"
runs-on: ubuntu-latest
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'ok-to-test') || github.event.inputs.version
strategy:
matrix:
installer-type: ["online", "offline"]
steps:
# Checkout source branch for testing
- name: Checkout PR
uses: actions/checkout@v4
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
with:
ref: ${{ github.event.pull_request.head.sha }}
# Checkout target branch for release build
- name: Checkout
uses: actions/checkout@v4
with:
ref: refs/tags/${{ github.event.inputs.version }}
if: github.event.inputs.version
- name: Set version from tag/branch
run: |
echo "RELEASE_VERSION=$GITHUB_REF_NAME" >>"$GITHUB_ENV"
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'ok-to-test')
- name: Set version from input
run: |
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >>"$GITHUB_ENV"
if: github.event.inputs.version
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.21
id: go
- name: Get dependencies
run: |
go install -v ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Log into docker for registry.redhat.io
uses: docker/login-action@v2
with:
registry: registry.redhat.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build tarfile
run: CLIENT=docker make build-${{ matrix.installer-type }}-zip
- name: Upload tarfile
uses: actions/upload-artifact@v3
with:
name: mirror-registry-${{ matrix.installer-type }}-installer
path: mirror-registry.tar.gz
retention-days: 1
test-remote-install:
name: "Remote Install"
needs: ["build-install-zip"]
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') # Skip on release
strategy:
fail-fast: false
matrix:
installer-type: ["online", "offline"]
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
TF_VAR_SSH_PUBLIC_KEY: ${{ secrets.TF_VAR_SSH_PUBLIC_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install oc
uses: redhat-actions/oc-installer@v1
with:
oc_version: "4.6"
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
# terraform_version: 0.13.0:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_wrapper: false
- name: Install SSH Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.TF_VAR_SSH_PRIVATE_KEY }}
- name: Write SSH Key id_rsa
run: |
echo "$SSH_KEY" > /home/runner/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
env:
SSH_KEY: ${{ secrets.TF_VAR_SSH_PRIVATE_KEY }}
- name: Write SSH Key staging.key
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/staging.key
chmod 600 ~/.ssh/staging.key
cat >>~/.ssh/config <<END
Host quay
HostName quay
User jonathan
IdentityFile ~/.ssh/staging.key
StrictHostKeyChecking no
END
env:
SSH_KEY: ${{ secrets.TF_VAR_SSH_PRIVATE_KEY }}
- name: Initialize VM
uses: ./.github/actions/setup-terraform
with:
terraform-context: ".github/workflows/remote-${{ matrix.installer-type }}-installer"
- name: Wait for VM
uses: jakejarvis/wait-action@master
with:
time: "60s"
- name: Download tarfile
uses: actions/download-artifact@v3
with:
name: mirror-registry-${{ matrix.installer-type }}-installer
- name: Extract tarfile
run: tar -xf mirror-registry.tar.gz
- name: Add quay to /etc/hosts
run: ssh jonathan@quay 'echo "127.0.0.1 quay" | sudo tee -a /etc/hosts'
- name: Install podman
run: ssh jonathan@quay 'sudo subscription-manager refresh; sudo yum -y install podman'
- name: Log into podman for registry.redhat.io
run: ssh jonathan@quay "podman login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} registry.redhat.io"
if: matrix.installer-type == 'online'
- name: Install Registry
run: ./mirror-registry install -u jonathan -r /home/jonathan/quay-install -H quay -v --initPassword password -k /home/runner/.ssh/id_rsa
- name: Mirror Images
uses: ./.github/actions/mirror
with:
quay-hostname: "quay:8443"
pull-secret: ${{ secrets.PULL_SECRET }}
- name: Upgrade Registry
run: ./mirror-registry upgrade -u jonathan -r /home/jonathan/quay-install -H quay -v -k /home/runner/.ssh/id_rsa
- name: Uninstall Registry
run: ./mirror-registry uninstall -u jonathan -H quay --autoApprove -v -k /home/runner/.ssh/id_rsa
- name: Download old mirror-registry tarball that runs quay with postgres
run: wget -O mirror-registry-postgres.tar.gz "https://github.com/quay/mirror-registry/releases/download/v1.3.10/mirror-registry-${{ matrix.installer-type }}.tar.gz"
- name: Create extraction directory for old mirror-registry binary
run: mkdir -p ./mirror-registry-postgres
- name: Extract tarball into the folder
run: tar -xzf mirror-registry-postgres.tar.gz -C ./mirror-registry-postgres
- name: Install postgres backed quay registry
run: ./mirror-registry-postgres/mirror-registry install -u jonathan -r /home/jonathan/quay-install -H quay -v --initPassword password -k /home/runner/.ssh/id_rsa
- name: Podman login to quay registry
run: podman login -u init -p password quay:8443 --tls-verify=false
- name: Pull busybox image from Docker Hub
run: podman pull docker.io/library/busybox
- name: Tag busybox image for Quay
run: podman tag docker.io/library/busybox quay:8443/init/busybox:latest
- name: Push busybox image to Quay
run: podman push quay:8443/init/busybox:latest --tls-verify=false
- name: Use latest binary to test upgrade cmd to ensure db migration from old postgres to sqlite
run: ./mirror-registry upgrade -u jonathan -r /home/jonathan/quay-install -H quay -v -k /home/runner/.ssh/id_rsa
- name: Pull already pushed busybox image from quay registry
run: podman pull quay:8443/init/busybox:latest --tls-verify=false
- name: Verify busybox image is pulled successfully
run: podman images | grep -q quay:8443/init/busybox
- name: Uninstall Registry
run: ./mirror-registry uninstall -u jonathan -H quay --autoApprove -v -k /home/runner/.ssh/id_rsa
- name: Terraform Destroy
run: terraform destroy --auto-approve
shell: bash
working-directory: ".github/workflows/remote-${{ matrix.installer-type }}-installer"
if: always()
test-local-install:
name: "Local Install"
needs: ["build-install-zip"]
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') # Skip on release
strategy:
fail-fast: false
matrix:
installer-type: ["online", "offline"]
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
TF_VAR_SSH_PUBLIC_KEY: ${{ secrets.TF_VAR_SSH_PUBLIC_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install oc
uses: redhat-actions/oc-installer@v1
with:
oc_version: "4.6"
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
# terraform_version: 0.13.0:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_wrapper: false
- name: Install SSH Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.TF_VAR_SSH_PRIVATE_KEY }}
- name: Write SSH Key id_rsa
run: |
echo "$SSH_KEY" > /home/runner/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
env:
SSH_KEY: ${{ secrets.TF_VAR_SSH_PRIVATE_KEY }}
- name: Write SSH Key staging.key
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/staging.key
chmod 600 ~/.ssh/staging.key
cat >>~/.ssh/config <<END
Host quay
HostName quay
User jonathan
IdentityFile ~/.ssh/staging.key
StrictHostKeyChecking no
END
env:
SSH_KEY: ${{ secrets.TF_VAR_SSH_PRIVATE_KEY }}
- name: Initialize VM
uses: ./.github/actions/setup-terraform
with:
terraform-context: ".github/workflows/local-${{ matrix.installer-type }}-installer"
- name: Wait for VM
uses: jakejarvis/wait-action@master
with:
time: "60s"
- name: Download tarfile
uses: actions/download-artifact@v3
with:
name: mirror-registry-${{ matrix.installer-type }}-installer
- name: SCP tarball to VM
run: scp mirror-registry.tar.gz jonathan@quay:~/mirror-registry.tar.gz
- name: Add quay to /etc/hosts
run: ssh jonathan@quay 'echo "127.0.0.1 quay" | sudo tee -a /etc/hosts'
- name: Install podman
run: ssh jonathan@quay 'sudo subscription-manager refresh; sudo yum -y install podman'
- name: Log into podman for registry.redhat.io
run: ssh jonathan@quay "podman login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} registry.redhat.io"
if: matrix.installer-type == 'online'
- name: Pull busybox image from Docker Hub before disabling traffic
run: ssh jonathan@quay 'podman pull docker.io/library/busybox'
- name: Disable outbound network traffic
run: ssh jonathan@quay 'sudo firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -m state --state ESTABLISHED,RELATED -j ACCEPT; sudo firewall-cmd --direct --add-rule ipv4 filter OUTPUT 1 -p tcp -m tcp --dport=22 -j ACCEPT; sudo firewall-cmd --direct --add-rule ipv4 filter OUTPUT 1 -p tcp -m tcp --dport=8443 -j ACCEPT; sudo firewall-cmd --direct --add-rule ipv4 filter OUTPUT 2 -j DROP'
if: matrix.installer-type == 'offline'
- name: Install Registry
run: ssh jonathan@quay 'tar -xf mirror-registry.tar.gz; ./mirror-registry install -v --quayHostname quay:8443 --initPassword password'
- name: Mirror Images
uses: ./.github/actions/mirror
with:
quay-hostname: "quay:8443"
pull-secret: ${{ secrets.PULL_SECRET }}
- name: Upgrade Quay
run: ssh jonathan@quay './mirror-registry upgrade -v'
- name: Uninstall Quay
run: ssh jonathan@quay './mirror-registry uninstall --autoApprove -v'
- name: Download old mirror-registry tarball that runs quay with postgres
run: wget -O mirror-registry-postgres.tar.gz "https://github.com/quay/mirror-registry/releases/download/v1.3.10/mirror-registry-${{ matrix.installer-type }}.tar.gz"
- name: SCP old tarball to VM
run: scp mirror-registry-postgres.tar.gz jonathan@quay:~/mirror-registry-postgres.tar.gz
- name: Create extraction directory for old mirror-registry binary
run: ssh jonathan@quay 'mkdir -p ./mirror-registry-postgres'
- name: Extract tarball into the folder
run: ssh jonathan@quay 'tar -xzf mirror-registry-postgres.tar.gz -C ./mirror-registry-postgres'
- name: Install postgres backed quay registry
run: ssh jonathan@quay './mirror-registry-postgres/mirror-registry install -u jonathan -r /home/jonathan/quay-install --quayHostname quay:8443 -v --initPassword password'
- name: Podman login to quay registry
run: ssh jonathan@quay 'podman login -u init -p password quay:8443 --tls-verify=false'
- name: Tag busybox image for Quay
run: ssh jonathan@quay 'podman tag docker.io/library/busybox quay:8443/init/busybox:latest'
- name: Push busybox image to Quay
run: ssh jonathan@quay 'podman push quay:8443/init/busybox:latest --tls-verify=false'
- name: Use latest binary to test upgrade cmd to ensure db migration from old postgres to sqlite
run: ssh jonathan@quay './mirror-registry upgrade -u jonathan -r /home/jonathan/quay-install --quayHostname quay:8443 -v'
- name: Pull already pushed busybox image from quay registry
run: ssh jonathan@quay 'podman pull quay:8443/init/busybox:latest --tls-verify=false'
- name: Verify busybox image was pulled successfully
run: ssh jonathan@quay 'podman images | grep -q quay:8443/init/busybox'
- name: Uninstall Quay
run: ssh jonathan@quay './mirror-registry uninstall --autoApprove -v'
- name: Terraform Destroy
run: terraform destroy --auto-approve
shell: bash
working-directory: ".github/workflows/local-${{ matrix.installer-type }}-installer"
if: always()
publish-release:
name: "Publish Release"
needs: ["build-install-zip"]
runs-on: ubuntu-latest
permissions:
contents: write
if: github.event_name == 'push' || github.event.inputs.version
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download offline tarfile
uses: actions/download-artifact@v3
with:
name: mirror-registry-offline-installer
- name: Rename offline tarfile
run: mv mirror-registry.tar.gz mirror-registry-offline.tar.gz
- name: Download online tarfile
uses: actions/download-artifact@v3
with:
name: mirror-registry-online-installer
- name: Rename online tarfile
run: mv mirror-registry.tar.gz mirror-registry-online.tar.gz
- uses: ncipollo/release-action@v1
with:
artifacts: "*.tar.gz,README.md"
allowUpdates: true
prerelease: true
tag: ${{ github.ref_name }}
if: github.event_name == 'push'
- uses: ncipollo/release-action@v1
with:
artifacts: "*.tar.gz,README.md"
allowUpdates: true
prerelease: true
tag: ${{ github.event.inputs.version }}
if: github.event.inputs.version