-
Notifications
You must be signed in to change notification settings - Fork 134
391 lines (365 loc) · 18.8 KB
/
main.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
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
# temporarily run on every push for testing
# branches: [ master ]
# pull_request:
# branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
# ┌──────────────────┐ ┌────────────────┐ ┌────────────────┐
# ┌─────────┐ ┌─────────┬────► Build Latest NJS ├────────►Test Latest NJS ├─────►│Push Latest NJS │
# │Build OSS├────►│Test OSS │ └──────────────────┘ └────────────────┘ └────────────────┘
# └─────────┘ └──┬──────┤
# │ │ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────────┐
# │ └────►Build Unprivileged├───────►Test Unprivileged ├────►│Push Unprivileged│
# │ └──────────────────┘ └──────────────────┘ ├────────┬────────┘
# │ ├────────┤
# └──────────────────────────────────────────────────────────────►│Push OSS│
# └────────┘
jobs:
build-oss-for-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export
uses: docker/build-push-action@v5
with:
file: Dockerfile.oss
context: .
tags: nginx-s3-gateway , nginx-s3-gateway:oss
outputs: type=docker,dest=/tmp/oss.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: oss
path: /tmp/oss.tar
# steps:
# - uses: actions/checkout@v4
# # Build again to export the file locally so we can save all arch versions.
# - name: Build and export oss image
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# with:
# driver: docker
# uses: docker/build-push-action@v5
# with:
# file: Dockerfile.oss
# context: .
# tags: nginx-s3-gateway , nginx-s3-gateway:oss
# load: true
# - name: save image for upload
# run: |
# run: |
# docker save nginx-s3-gateway > oss.tar
# - name: Upload artifact - oss
# uses: actions/upload-artifact@v3
# with:
# name: oss
# path: /tmp/oss.tar
test-oss:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/master'
needs: build-oss-for-test
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update -qq && sudo apt-get install -y curl wait-for-it
- name: Restore cached binaries
id: cache-binaries-restore
uses: actions/cache/restore@v3
with:
path: .bin
key: ${{ runner.os }}-binaries
- name: Install MinIO Client
run: |
mkdir .bin || exit 0
cd .bin
curl --insecure --retry 6 --fail --location --output mc.RELEASE.2023-06-19T19-31-19Z "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z"
curl --insecure --retry 6 --fail --silent --location "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z.sha256sum" | sha256sum --check -
mv mc.RELEASE.2023-06-19T19-31-19Z mc
chmod +x mc
## OSS Test. No retagging needed
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: oss
path: /tmp
- name: Load image
run: |
docker load --input /tmp/oss.tar
- name: Run tests - stable njs version
run: ./test.sh --type oss
build-latest-njs-for-test:
runs-on: ubuntu-latest
needs: test-oss
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: oss
path: /tmp
- name: Load image
run: |
docker load --input /tmp/oss.tar
- name: Build and load oss image
uses: docker/build-push-action@v5
with:
file: Dockerfile.latest-njs
context: .
tags: nginx-s3-gateway:latest-njs-oss
load: true
- name: save image
run: |
docker save nginx-s3-gateway:latest-njs-oss > /tmp/latest-njs.tar
- name: Upload artifact - latest-njs
uses: actions/upload-artifact@v3
with:
name: latest-njs
path: /tmp/latest-njs.tar
test-latest-njs:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/master'
needs: build-latest-njs-for-test
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update -qq && sudo apt-get install -y curl wait-for-it
- name: Restore cached binaries
id: cache-binaries-restore
uses: actions/cache/restore@v3
with:
path: .bin
key: ${{ runner.os }}-binaries
- name: Install MinIO Client
run: |
mkdir .bin || exit 0
cd .bin
curl --insecure --retry 6 --fail --location --output mc.RELEASE.2023-06-19T19-31-19Z "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z"
curl --insecure --retry 6 --fail --silent --location "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z.sha256sum" | sha256sum --check -
mv mc.RELEASE.2023-06-19T19-31-19Z mc
chmod +x mc
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: latest-njs
path: /tmp
- name: Load image
run: |
docker load --input /tmp/latest-njs.tar
docker tag nginx-s3-gateway:latest-njs-oss nginx-s3-gateway
- name: Run tests - latest njs version
run: ./test.sh --latest-njs --type oss
build-unprivileged-for-test:
runs-on: ubuntu-latest
needs: test-oss
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: oss
path: /tmp
- name: Load image
run: |
docker load --input /tmp/oss.tar
- name: Build and load oss image
uses: docker/build-push-action@v5
with:
file: Dockerfile.unprivileged
context: .
tags: nginx-s3-gateway:unprivileged-oss
load: true
# Save manually here since we need to use the `docker` buildx `driver` but that can't output
# a file that upload-artifact likes.
- name: save image
run: |
docker save nginx-s3-gateway:unprivileged-oss > /tmp/unprivileged.tar
- name: Upload artifact - unprivileged
uses: actions/upload-artifact@v3
with:
name: unprivileged
path: /tmp/unprivileged.tar
test-unprivileged:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/master'
needs: build-unprivileged-for-test
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update -qq && sudo apt-get install -y curl wait-for-it
- name: Restore cached binaries
id: cache-binaries-restore
uses: actions/cache/restore@v3
with:
path: .bin
key: ${{ runner.os }}-binaries
- name: Install MinIO Client
run: |
mkdir .bin || exit 0
cd .bin
curl --insecure --retry 6 --fail --location --output mc.RELEASE.2023-06-19T19-31-19Z "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z"
curl --insecure --retry 6 --fail --silent --location "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z.sha256sum" | sha256sum --check -
mv mc.RELEASE.2023-06-19T19-31-19Z mc
chmod +x mc
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: unprivileged
path: /tmp
- name: Load image
run: |
docker load --input /tmp/unprivileged.tar
docker tag nginx-s3-gateway:unprivileged-oss nginx-s3-gateway
- name: Run tests - unprivileged
run: ./test.sh --unprivileged --type oss
# After the tests are done, build multiarch and push to both github packages and dockerhub if we are on master/main
# tag-and-push:
# runs-on: ubuntu-latest
# needs: [test-oss, test-latest-njs, test-unprivileged]
# if: |
# github.ref == 'refs/heads/master' ||
# github.ref == 'refs/heads/main'
# steps:
# - name: Get current date
# id: date
# run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
# - name: Configure Github Package Registry
# run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
# - name: Download artifact - oss
# uses: actions/download-artifact@v3
# with:
# name: oss
# path: /tmp
# - name: Download artifact - latest-njs
# uses: actions/download-artifact@v3
# with:
# name: latest-njs
# path: /tmp
# - name: Download artifact - unprivileged
# uses: actions/download-artifact@v3
# with:
# name: unprivileged
# path: /tmp
# - name: Load and retag oss image [oss]
# run: |
# docker load --input /tmp/oss.tar
# docker tag localhost:5000/nginx-s3-gateway docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-${{ steps.date.outputs.date }}-new-build-test
# docker tag localhost:5000/nginx-s3-gateway docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-new-build-test
# - name: Push container image to github [oss date]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-${{ steps.date.outputs.date }}-new-build-test
# - name: Push container image to github [oss latest]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-new-build-test
# - name: Load and retag oss image [latest-njs-oss]
# run: |
# docker load --input /tmp/latest-njs.tar
# docker tag localhost:5000/nginx-s3-gateway::latest-njs-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}-new-build-test
# docker tag localhost:5000/nginx-s3-gateway::latest-njs-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-new-build-test
# - name: Push container image to github [latest-njs-oss date]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}-new-build-test
# - name: Push container image to github [latest-njs-oss]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-new-build-test
# # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# - uses: actions/checkout@v2
# - name: Get current date
# id: date
# run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
# - name: Configure Github Package Registry
# run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
# - name: Install dependencies
# run: sudo apt-get update -qq && sudo apt-get install -y curl wait-for-it
# - name: Restore cached binaries
# id: cache-binaries-restore
# uses: actions/cache/restore@v3
# with:
# path: .bin
# key: ${{ runner.os }}-binaries
# - name: Install MinIO Client
# run: |
# mkdir .bin || exit 0
# cd .bin
# curl --insecure --retry 6 --fail --silent --location --output mc.RELEASE.2023-06-19T19-31-19Z "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z"
# curl --insecure --retry 6 --fail --silent --location "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z.sha256sum" | sha256sum --check -
# mv mc.RELEASE.2023-06-19T19-31-19Z mc
# chmod +x mc
# # Run tests and builds image
# - name: Run tests - latest njs version
# run: ./test.sh --latest-njs --type oss
# # latest-njs-oss image push [Github]
# - name: Tag container image for Push to github [latest-njs-oss date]
# run: docker tag nginx-s3-gateway:latest-njs-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}
# - name: Tag container image for Push to github [latest-njs-oss]
# run: docker tag nginx-s3-gateway:latest-njs-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss
# - name: Push container image to github [latest-njs-oss date]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}
# - name: Push container image to github [latest-njs-oss]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-njs-oss
# # Run tests and builds image
# - name: Run tests - stable njs version - unprivileged process
# run: ./test.sh --unprivileged --type oss
# # unprivileged-oss image push [Github]
# - name: Tag container image for Push to github [unprivileged-oss date]
# run: docker tag nginx-s3-gateway:unprivileged-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:unprivileged-oss-${{ steps.date.outputs.date }}
# - name: Tag container image for Push to github [unprivileged-oss]
# run: docker tag nginx-s3-gateway:unprivileged-oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:unprivileged-oss
# - name: Push container image to github [unprivileged-oss date]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:unprivileged-oss-${{ steps.date.outputs.date }}
# - name: Push container image to github [unprivileged-oss]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:unprivileged-oss
# # Run tests and builds image
# - name: Run tests - stable njs version
# run: ./test.sh --type oss
# # oss image push [Github]
# - name: Tag container image for Push to github [oss date]
# run: docker tag nginx-s3-gateway:oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-${{ steps.date.outputs.date }}
# - name: Tag container image for Push to github [oss]
# run: docker tag nginx-s3-gateway:oss docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest
# - name: Push container image to github [oss date]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest-${{ steps.date.outputs.date }}
# - name: Push container image to github [oss latest]
# run: docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway:latest
# # Login to Docker Hub
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# # latest-njs-oss image push [Docker Hub]
# - name: Tag container image for Push to Docker Hub [latest-njs-oss date]
# run: docker tag nginx-s3-gateway:latest-njs-oss nginxinc/nginx-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}
# - name: Tag container image for Push to Docker Hub [latest-njs-oss]
# run: docker tag nginx-s3-gateway:latest-njs-oss nginxinc/nginx-s3-gateway:latest-njs-oss
# - name: Push container image to Docker Hub [latest-njs-oss date]
# run: docker push nginxinc/nginx-s3-gateway:latest-njs-oss-${{ steps.date.outputs.date }}
# - name: Push container image to Docker Hub [latest-njs-oss]
# run: docker push nginxinc/nginx-s3-gateway:latest-njs-oss
# # unprivileged-oss image push [Docker Hub]
# - name: Tag container image for Push to Docker Hub [unprivileged-oss date]
# run: docker tag nginx-s3-gateway:unprivileged-oss nginxinc/nginx-s3-gateway:unprivileged-oss-${{ steps.date.outputs.date }}
# - name: Tag container image for Push to Docker Hub [unprivileged-oss]
# run: docker tag nginx-s3-gateway:unprivileged-oss nginxinc/nginx-s3-gateway:unprivileged-oss
# - name: Push container image to Docker Hub [unprivileged-oss date]
# run: docker push nginxinc/nginx-s3-gateway:unprivileged-oss-${{ steps.date.outputs.date }}
# - name: Push container image to Docker Hub [unprivileged-oss]
# run: docker push nginxinc/nginx-s3-gateway:unprivileged-oss
# # oss image push [Docker Hub]
# - name: Tag container image for Push to Docker Hub [oss date]
# run: docker tag nginx-s3-gateway:oss nginxinc/nginx-s3-gateway:latest-${{ steps.date.outputs.date }}
# - name: Tag container image for Push to Docker Hub [oss]
# run: docker tag nginx-s3-gateway:oss nginxinc/nginx-s3-gateway:latest
# - name: Push container image to Docker Hub [oss date]
# run: docker push nginxinc/nginx-s3-gateway:latest-${{ steps.date.outputs.date }}
# - name: Push container image to Docker Hub [oss latest]
# run: docker push nginxinc/nginx-s3-gateway:latest