36
36
RUN_TMATE : ${{ secrets.RUN_TMATE }}
37
37
38
38
jobs :
39
+ diagnostics :
40
+ name : Run diagnostics
41
+ runs-on : ubuntu-latest
42
+ steps :
43
+ # Note that a duplicate of this step must be added at the top of
44
+ # each job.
45
+ - id : harden-runner
46
+ name : Harden the runner
47
+ uses : step-security/harden-runner@v2
48
+ with :
49
+ egress-policy : audit
50
+ - id : github-status
51
+ name : Check GitHub status
52
+ uses : crazy-max/ghaction-github-status@v3
53
+ - id : dump-context
54
+ name : Dump context
55
+ uses : crazy-max/ghaction-dump-context@v2
39
56
lint :
40
57
# Checks out the source and runs pre-commit hooks. Detects coding errors
41
58
# and style deviations.
42
- name : " Lint sources"
59
+ name : Lint sources
60
+ needs :
61
+ - diagnostics
43
62
runs-on : ubuntu-latest
44
63
steps :
64
+ - id : harden-runner
65
+ name : Harden the runner
66
+ uses : step-security/harden-runner@v2
67
+ with :
68
+ egress-policy : audit
45
69
- id : setup-env
46
70
uses : cisagov/setup-env-github-action@develop
47
- - uses : actions/checkout@v3
71
+ - uses : actions/checkout@v4
48
72
- id : setup-python
49
73
uses : actions/setup-python@v4
50
74
with :
@@ -105,11 +129,26 @@ jobs:
105
129
- uses : hashicorp/setup-terraform@v2
106
130
with :
107
131
terraform_version : ${{ steps.setup-env.outputs.terraform-version }}
132
+ - name : Install go-critic
133
+ env :
134
+ PACKAGE_URL : github.com/go-critic/go-critic/cmd/gocritic
135
+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.go-critic-version }}
136
+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
137
+ - name : Install gosec
138
+ env :
139
+ PACKAGE_URL : github.com/securego/gosec/v2/cmd/gosec
140
+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.gosec-version }}
141
+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
108
142
- name : Install shfmt
109
143
env :
110
144
PACKAGE_URL : mvdan.cc/sh/v3/cmd/shfmt
111
145
PACKAGE_VERSION : ${{ steps.setup-env.outputs.shfmt-version }}
112
146
run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
147
+ - name : Install staticcheck
148
+ env :
149
+ PACKAGE_URL : honnef.co/go/tools/cmd/staticcheck
150
+ PACKAGE_VERSION : ${{ steps.setup-env.outputs.staticcheck-version }}
151
+ run : go install ${PACKAGE_URL}@${PACKAGE_VERSION}
113
152
- name : Install Terraform-docs
114
153
env :
115
154
PACKAGE_URL : github.com/terraform-docs/terraform-docs
@@ -167,18 +206,25 @@ jobs:
167
206
# with the value specified by the user.
168
207
#
169
208
# Scheduled builds are tagged with `:nightly`.
170
- name : " Prepare build variables"
171
- runs-on : ubuntu-latest
209
+ name : Prepare build variables
210
+ needs :
211
+ - diagnostics
172
212
outputs :
173
213
created : ${{ steps.prep.outputs.created }}
174
214
repometa : ${{ steps.repo.outputs.result }}
175
215
source_version : ${{ steps.prep.outputs.source_version }}
176
216
tags : ${{ steps.prep.outputs.tags }}
217
+ runs-on : ubuntu-latest
177
218
steps :
178
- - uses : actions/checkout@v3
219
+ - id : harden-runner
220
+ name : Harden the runner
221
+ uses : step-security/harden-runner@v2
222
+ with :
223
+ egress-policy : audit
224
+ - uses : actions/checkout@v4
179
225
- name : Gather repository metadata
180
226
id : repo
181
- uses : actions/github-script@v6
227
+ uses : actions/github-script@v7
182
228
with :
183
229
script : |
184
230
const repo = await github.rest.repos.get(context.repo)
@@ -229,16 +275,23 @@ jobs:
229
275
build :
230
276
# Builds a single test image for the native platform. This image is saved
231
277
# as an artifact and loaded by the test job.
232
- name : " Build test image"
278
+ name : Build test image
279
+ needs :
280
+ - diagnostics
281
+ - prepare
233
282
runs-on : ubuntu-latest
234
- needs : [prepare]
235
283
steps :
284
+ - id : harden-runner
285
+ name : Harden the runner
286
+ uses : step-security/harden-runner@v2
287
+ with :
288
+ egress-policy : audit
236
289
- name : Checkout
237
- uses : actions/checkout@v3
290
+ uses : actions/checkout@v4
238
291
- name : Set up QEMU
239
- uses : docker/setup-qemu-action@v2
292
+ uses : docker/setup-qemu-action@v3
240
293
- name : Set up Docker Buildx
241
- uses : docker/setup-buildx-action@v2
294
+ uses : docker/setup-buildx-action@v3
242
295
- name : Cache Docker layers
243
296
uses : actions/cache@v3
244
297
env :
@@ -252,7 +305,7 @@ jobs:
252
305
run : mkdir -p dist
253
306
- name : Build image
254
307
id : docker_build
255
- uses : docker/build-push-action@v4
308
+ uses : docker/build-push-action@v5
256
309
with :
257
310
build-args : |
258
311
VERSION=${{ needs.prepare.outputs.source_version }}
@@ -261,6 +314,11 @@ jobs:
261
314
context : .
262
315
file : ./Dockerfile
263
316
outputs : type=docker,dest=dist/image.tar
317
+ # Uncomment the following option if you are building an image for use
318
+ # on Google Cloud Run or AWS Lambda. The current default image output
319
+ # is unable to run on either. Please see the following issue for more
320
+ # information: https://github.com/docker/buildx/issues/1533
321
+ # provenance: false
264
322
tags : ${{ env.IMAGE_NAME }}:latest # not to be pushed
265
323
# For a list of pre-defined annotation keys and value types see:
266
324
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
@@ -299,11 +357,18 @@ jobs:
299
357
if : env.RUN_TMATE
300
358
test :
301
359
# Executes tests on the single-platform image created in the "build" job.
302
- name : " Test image"
360
+ name : Test image
361
+ needs :
362
+ - diagnostics
363
+ - build
303
364
runs-on : ubuntu-latest
304
- needs : [build]
305
365
steps :
306
- - uses : actions/checkout@v3
366
+ - id : harden-runner
367
+ name : Harden the runner
368
+ uses : step-security/harden-runner@v2
369
+ with :
370
+ egress-policy : audit
371
+ - uses : actions/checkout@v4
307
372
- id : setup-python
308
373
uses : actions/setup-python@v4
309
374
with :
@@ -345,32 +410,41 @@ jobs:
345
410
# GitHub Container Registry. The contents of README.md are pushed as the
346
411
# image's description to Docker Hub. This job is skipped when the
347
412
# triggering event is a pull request.
348
- name : " Build and push all platforms"
349
- runs-on : ubuntu-latest
350
- needs : [lint, prepare, test]
351
413
if : github.event_name != 'pull_request'
414
+ name : Build and push all platforms
415
+ needs :
416
+ - diagnostics
417
+ - lint
418
+ - prepare
419
+ - test
352
420
# When Dependabot creates a PR it requires this permission in
353
421
# order to push Docker images to ghcr.io.
354
422
permissions :
355
423
packages : write
424
+ runs-on : ubuntu-latest
356
425
steps :
426
+ - id : harden-runner
427
+ name : Harden the runner
428
+ uses : step-security/harden-runner@v2
429
+ with :
430
+ egress-policy : audit
357
431
- name : Login to Docker Hub
358
- uses : docker/login-action@v2
432
+ uses : docker/login-action@v3
359
433
with :
360
434
username : ${{ secrets.DOCKER_USERNAME }}
361
435
password : ${{ secrets.DOCKER_PASSWORD }}
362
436
- name : Login to GitHub Container Registry
363
- uses : docker/login-action@v2
437
+ uses : docker/login-action@v3
364
438
with :
365
439
registry : ghcr.io
366
440
username : ${{ github.actor }}
367
441
password : ${{ secrets.GITHUB_TOKEN }}
368
442
- name : Checkout
369
- uses : actions/checkout@v3
443
+ uses : actions/checkout@v4
370
444
- name : Set up QEMU
371
- uses : docker/setup-qemu-action@v2
445
+ uses : docker/setup-qemu-action@v3
372
446
- name : Set up Docker Buildx
373
- uses : docker/setup-buildx-action@v2
447
+ uses : docker/setup-buildx-action@v3
374
448
- name : Cache Docker layers
375
449
uses : actions/cache@v3
376
450
env :
@@ -384,7 +458,7 @@ jobs:
384
458
run : ./buildx-dockerfile.sh
385
459
- name : Build and push platform images to registries
386
460
id : docker_build
387
- uses : docker/build-push-action@v4
461
+ uses : docker/build-push-action@v5
388
462
with :
389
463
build-args : |
390
464
VERSION=${{ needs.prepare.outputs.source_version }}
@@ -393,6 +467,11 @@ jobs:
393
467
context : .
394
468
file : ./Dockerfile-x
395
469
platforms : ${{ env.PLATFORMS }}
470
+ # Uncomment the following option if you are building an image for use
471
+ # on Google Cloud Run or AWS Lambda. The current default image output
472
+ # is unable to run on either. Please see the following issue for more
473
+ # information: https://github.com/docker/buildx/issues/1533
474
+ # provenance: false
396
475
push : true
397
476
tags : ${{ needs.prepare.outputs.tags }}
398
477
# For a list of pre-defined annotation keys and value types see:
0 commit comments