1
1
name : Publish Docker Image
2
2
on :
3
3
schedule :
4
- # Once weekly on fridays at noon
4
+ # Once weekly on Fridays at noon
5
5
- cron : " 00 12 * * 5"
6
6
workflow_dispatch :
7
7
@@ -20,25 +20,25 @@ jobs:
20
20
IMAGE_NAME : ${{ github.repository }}
21
21
steps :
22
22
- name : Checkout
23
- uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
23
+ uses : actions/checkout@v4
24
24
- name : Set up QEMU for cross-platform builds
25
- uses : docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
25
+ uses : docker/setup-qemu-action@v3
26
26
- name : Set up Docker Buildx
27
- uses : docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
27
+ uses : docker/setup-buildx-action@v3
28
28
- name : Compute version number
29
29
id : version-string
30
30
run : |
31
31
DATE="$(date +%Y%m%d)"
32
32
COMMIT="$(git rev-parse --short HEAD)"
33
- echo "tag=0.$DATE.$GITHUB_RUN_NUMBER+ ref.$COMMIT" >> "$GITHUB_OUTPUT"
33
+ echo "tag=0.$DATE.$GITHUB_RUN_NUMBER- ref.$COMMIT" >> "$GITHUB_OUTPUT"
34
34
- name : Login to GHCR
35
- uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
35
+ uses : docker/login-action@v3
36
36
with :
37
37
registry : ghcr.io
38
38
username : ${{ github.actor }}
39
39
password : ${{ secrets.GITHUB_TOKEN }}
40
40
- name : Set container metadata
41
- uses : docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
41
+ uses : docker/metadata-action@v5
42
42
id : docker-metadata
43
43
with :
44
44
images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
@@ -73,15 +73,13 @@ jobs:
73
73
run : |
74
74
git lfs install
75
75
git lfs pull
76
- - name : Build image
76
+ - name : Build and Push Image
77
77
id : image-build
78
- uses : docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v5
78
+ uses : docker/build-push-action@v5
79
79
with :
80
- github-token : ${{ github.token }}
81
80
context : .
82
81
platforms : linux/amd64,linux/arm64
83
82
push : true
84
- file : ./Dockerfile
85
83
tags : ${{ steps.docker-metadata.outputs.tags }}
86
84
labels : ${{ steps.docker-metadata.outputs.labels }}
87
85
cache-from : type=gha
@@ -90,15 +88,30 @@ jobs:
90
88
gh_token=${{ secrets.GH_CI_TOKEN }}
91
89
build-args : |
92
90
LATEST_COMMIT_SHA=${{ env.LATEST_COMMIT_SHA }}
93
- - name : Install cosign
94
- if : github.event_name != 'pull_request'
95
- uses : sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
91
+ - name : Capture Image Digest
92
+ id : image-digest
93
+ run : |
94
+ echo "digest=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.version-string.outputs.tag }})" >> "$GITHUB_OUTPUT"
96
95
- name : Run Trivy vulnerability scanner
97
96
uses : aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # v0.29.0
98
97
with :
99
- image-ref : ' ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version-string .outputs.tag }}'
98
+ image-ref : ' ${{ steps.image-digest .outputs.digest }}'
100
99
format : ' table'
101
100
exit-code : ' 1'
102
101
ignore-unfixed : true
103
102
vuln-type : ' os,library'
104
103
severity : ' CRITICAL,HIGH'
104
+ - name : Install cosign
105
+ if : github.event_name != 'pull_request'
106
+ uses : sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
107
+ - name : Sign the images with GitHub OIDC Token
108
+ env :
109
+ DIGEST : ${{ steps.image-build.outputs.digest }}
110
+ TAGS : ${{ steps.docker-metadata.outputs.tags }}
111
+ run : |
112
+ images=""
113
+ for tag in ${TAGS}; do
114
+ images+="${tag}@${DIGEST} "
115
+ done
116
+ cosign sign --yes ${images}
117
+
0 commit comments