2121 - self-hosted
2222 - Linux
2323 - ${{ matrix.runner }}
24+
2425 strategy :
2526 matrix :
2627 cpu : [arm64, amd64]
@@ -31,23 +32,31 @@ jobs:
3132 - cpu : amd64
3233 runner : X64
3334 tag : amd64
35+
36+ permissions :
37+ contents : read
38+ packages : write
39+
3440 steps :
3541 - name : Checkout
3642 uses : actions/checkout@v4
3743 with :
3844 submodules : recursive
45+
3946 - name : Login to GitHub container registry
4047 uses : docker/login-action@v3
4148 with :
4249 registry : ghcr.io
4350 username : ${{ github.actor }}
4451 password : ${{ secrets.GITHUB_TOKEN }}
52+
4553 - name : Set up Docker Buildx
4654 uses : docker/setup-buildx-action@v3
4755 with :
4856 buildkitd-config-inline : |
4957 [registry."docker.io"]
5058 mirrors = ["dockerhub-proxy.teonite.net"]
59+
5160 - name : Build container
5261 uses : docker/build-push-action@v5
5362 with :
@@ -59,10 +68,30 @@ jobs:
5968 cache-from : type=gha
6069 cache-to : type=gha,mode=max
6170
71+ - name : Scan image with Trivy
72+ uses :
aquasecurity/[email protected] 73+ with :
74+ image-ref : " ${{ env.GHCR_REPO }}:${{ github.sha }}-${{ matrix.tag }}"
75+ format : " table"
76+ exit-code : " 1"
77+ ignore-unfixed : true
78+ vuln-type : " os,library"
79+ severity : " CRITICAL,HIGH,MEDIUM"
80+
6281 docker-manifest :
6382 runs-on : [self-hosted, Linux]
83+
84+ permissions :
85+ contents : read
86+ packages : write
87+ id-token : write # needed for signing the images with GitHub OIDC Token
88+
6489 needs : [build-docker]
90+
6591 steps :
92+ - name : Install Cosign
93+ 94+
6695 - name : Docker meta
6796 id : meta
6897 uses : docker/metadata-action@v5
@@ -71,12 +100,14 @@ jobs:
71100 ${{ env.GHCR_REPO }}
72101 flavor : ${{ inputs.flavor }}
73102 tags : ${{ inputs.tags }}
103+
74104 - name : Login to GitHub container registry
75105 uses : docker/login-action@v3
76106 with :
77107 registry : ghcr.io
78108 username : ${{ github.actor }}
79109 password : ${{ secrets.GITHUB_TOKEN }}
110+
80111 - name : Create and push manifests
81112 run : |
82113 tags='${{ env.GHCR_REPO }}:${{ github.sha }} ${{ steps.meta.outputs.tags }}'
@@ -86,3 +117,13 @@ jobs:
86117 docker manifest create ${tag} ${{ env.GHCR_REPO }}:${{ github.sha }}-amd64 ${{ env.GHCR_REPO }}:${{ github.sha }}-arm64
87118 docker manifest push ${tag}
88119 done
120+
121+ - name : Sign the images with GitHub OIDC Token
122+ run : |
123+ images='${{ env.GHCR_REPO }}:${{ github.sha }} ${{ steps.meta.outputs.tags }}'
124+ cosign sign --yes ${images}
125+
126+ - name : Verify image signatures
127+ run : |
128+ images='${{ env.GHCR_REPO }}:${{ github.sha }} ${{ steps.meta.outputs.tags }}'
129+ cosign verify ${images} --certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-identity-regexp="https://github.com/DefGuard/proxy" -o text
0 commit comments