-
Notifications
You must be signed in to change notification settings - Fork 2
163 lines (142 loc) · 5.14 KB
/
test.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
name: test pruner
on:
push:
paths:
- 'experimental/**'
- '.github/**'
workflow_dispatch:
defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'
permissions:
contents: read
jobs:
build_and_prune:
runs-on: "ubuntu-latest"
services:
registry:
image: registry:2
ports:
- 5000:5000
env:
REGISTRY_STORAGE: "s3"
REGISTRY_STORAGE_S3_BUCKET: "mockbucket"
REGISTRY_STORAGE_S3_V4AUTH: "false"
REGISTRY_STORAGE_S3_REGION: "generic"
REGISTRY_STORAGE_S3_REGIONENDPOINT: "http://s3mock:9090"
REGISTRY_STORAGE_S3_SECURE: "false"
REGISTRY_STORAGE_S3_ACCESSKEY: "123"
REGISTRY_STORAGE_S3_SECRETKEY: "123"
REGISTRY_STORAGE_REDIRECT_DISABLE: "true"
credentials:
username: oxpa
password: ${{ secrets.DOCKERHUB_PASS }}
s3mock:
image: adobe/s3mock
ports:
- 9090:9090
env:
initialBuckets: mockbucket
debug: true
credentials:
username: oxpa
password: ${{ secrets.DOCKERHUB_PASS }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build code
run: |
cd cmds/docker-distribution-pruner/
go get
go build
mv docker-distribution-pruner ../../
cd -
- name: Add bucket hostname
run: echo "127.0.0.1 mockbucket.s3mock s3mock" | sudo tee -a /etc/hosts
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: oxpa
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64v8, amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Build A as latest image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
env:
SOURCE_DATE_EPOCH: 123
with:
file: "examples/fixtures/Dockerfile"
context: "examples/fixtures/"
platforms: "amd64,arm64"
tags: "localhost:5000/image:latest"
outputs: type=registry,push=true,rewrite-timestamp=true
target: "A"
- name: Build B as latest image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
env:
SOURCE_DATE_EPOCH: 123
with:
file: "examples/fixtures/Dockerfile"
context: "examples/fixtures/"
platforms: "amd64,arm64"
tags: "localhost:5000/image:latest"
outputs: type=registry,push=true,rewrite-timestamp=true
target: "B"
- name: Build AB as latest image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
env:
SOURCE_DATE_EPOCH: 123
with:
file: "examples/fixtures/Dockerfile"
context: "examples/fixtures/"
platforms: "amd64,arm64"
tags: "localhost:5000/image:latest,localhost:5000/image:AB"
outputs: type=registry,push=true,rewrite-timestamp=true
target: "AB"
- name: Build A as latest and A
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
env:
SOURCE_DATE_EPOCH: 123
with:
file: "examples/fixtures/Dockerfile"
context: "examples/fixtures/"
platforms: "amd64,arm64"
tags: "localhost:5000/image:A,localhost:5000/image:latest"
outputs: type=registry,push=true,rewrite-timestamp=true
target: "A"
- name: Build AB for latest
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
env:
SOURCE_DATE_EPOCH: 123
with:
file: "examples/fixtures/Dockerfile"
context: "examples/fixtures/"
platforms: "amd64,arm64"
tags: "localhost:5000/image:latest"
outputs: type=registry,push=true,rewrite-timestamp=true
target: "AB"
- name: Install regctl
uses: iarekylew00t/regctl-installer@v2
- name: Test images can be downloaded
run: |
regctl --host reg=localhost:5000,tls=disabled tag list localhost:5000/image
for i in A AB latest; do
regctl --host reg=localhost:5000,tls=disabled image manifest localhost:5000/image:$i
regctl --host reg=localhost:5000,tls=disabled image export localhost:5000/image:$i > /dev/null
done
- name: Prune registry
run: |
EXPERIMENTAL=true ./docker-distribution-pruner -config examples/registry/s3config.yml -delete -trace
- name: Test images can be downloaded after pruning
run: |
regctl --host reg=localhost:5000,tls=disabled tag list localhost:5000/image
for i in A AB latest; do
regctl --host reg=localhost:5000,tls=disabled image manifest localhost:5000/image:$i
regctl --host reg=localhost:5000,tls=disabled image export localhost:5000/image:$i > /dev/null
done