77 flavor :
88 required : true
99 type : string
10+ enable-cache :
11+ required : false
12+ type : boolean
13+ default : true
1014
1115permissions :
1216 contents : read
1317
1418env :
19+ CONTAINER_FLAVOR : ${{ inputs.flavor }}
1520 REGISTRY : ghcr.io
1621
1722jobs :
4348 images : ${{ env.REGISTRY }}/${{ github.repository }}-${{ inputs.flavor }}
4449 # Generate image LABEL for devcontainer.metadata
4550 # the sed expression is a workaround for quotes being eaten in arrays (e.g. ["x", "y", "z"] -> ["x",y,"z"])
46- - run : echo "metadata=$(jq -cj '[.]' .devcontainer/${{ inputs.flavor }} /devcontainer-metadata-vscode.json | sed 's/,"/, "/g')" >> "$GITHUB_OUTPUT"
51+ - run : echo "metadata=$(jq -cj '[.]' " .devcontainer/${CONTAINER_FLAVOR} /devcontainer-metadata-vscode.json" | sed 's/,"/, "/g')" >> "$GITHUB_OUTPUT"
4752 id : devcontainer-metadata
4853 - run : echo "git-commit-epoch=$(git log -1 --pretty=%ct)" >> "$GITHUB_OUTPUT"
4954 id : devcontainer-epoch
@@ -63,13 +68,15 @@ jobs:
6368 annotations : ${{ steps.metadata.outputs.annotations }}
6469 sbom : true
6570 outputs : type=image,push-by-digest=true,name-canonical=true
66- cache-to : type=gha,mode=max,scope=${{ github.repository }}-${{ inputs.flavor }}-${{ matrix.runner }}
67- cache-from : type=gha,scope=${{ github.repository }}-${{ inputs.flavor }}-${{ matrix.runner }}
71+ cache-to : ${{ inputs.enable-cache && format(' type=gha,mode=max,scope={0}-{1}-{2}', github.repository, inputs.flavor, matrix.runner) || '' }}
72+ cache-from : ${{ inputs.enable-cache && format(' type=gha,scope={0}-{1}-{2}', github.repository, inputs.flavor, matrix.runner) || '' }}
6873 - name : Export digest
6974 run : |
75+ set -Eeuo pipefail
7076 mkdir -p ${{ runner.temp }}/digests
71- digest="${{ steps.build-and-push.outputs.digest }}"
72- touch "${{ runner.temp }}/digests/${digest#sha256:}"
77+ touch "${{ runner.temp }}/digests/${DIGEST#sha256:}"
78+ env :
79+ DIGEST : ${{ steps.build-and-push.outputs.digest }}
7380 - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
7481 with :
7582 name : digests-${{ inputs.flavor }}-${{ steps.devcontainer-arch.outputs.arch }}
@@ -123,15 +130,13 @@ jobs:
123130 type=semver,pattern={{major}}.{{minor}}
124131 type=semver,pattern={{major}}
125132 - name : Create manifest list and push
126- working-directory : ${{ runner.temp }}/digests
127- shell : python
128133 run : |
129134 import os
130135 import json
131136 import subprocess
132137
133- CONTAINER = '${{ env. REGISTRY }} /${{ github.repository }}-${{ inputs.flavor }}'
134- METADATA = json.loads('${{ steps.metadata.outputs.json }}' )
138+ CONTAINER = f"{os.getenv(' REGISTRY')} /${{ github.repository }}-{os.getenv('CONTAINER_FLAVOR')}"
139+ METADATA = json.loads(os.getenv('METADATA_JSON') )
135140
136141 digests = [f for f in os.listdir('.') if f.startswith('sha256:') or len(f) == 64]
137142
@@ -143,12 +148,18 @@ jobs:
143148
144149 print(' '.join(command))
145150 subprocess.run(command, check=True)
151+ env :
152+ METADATA_JSON : ${{ steps.metadata.outputs.json }}
153+ shell : python
154+ working-directory : ${{ runner.temp }}/digests
146155 - name : Inspect manifest and extract digest
147156 id : inspect-manifest
148157 run : |
149158 set -Eeuo pipefail
150- output=$(docker buildx imagetools inspect ${{ env. REGISTRY }} /${{ github.repository }}-${{ inputs.flavor }} :${{ steps.metadata.outputs.version }} --format '{{json .}}')
159+ output=$(docker buildx imagetools inspect "${ REGISTRY} /${{ github.repository }}-${CONTAINER_FLAVOR} :${CONTAINER_VERSION}" --format '{{json .}}')
151160 echo "digest=$(echo "$output" | jq -r '.manifest.digest // .manifests[0].digest')" >> "$GITHUB_OUTPUT"
161+ env :
162+ CONTAINER_VERSION : ${{ steps.metadata.outputs.version }}
152163 - uses : ./.github/actions/container-size-diff
153164 id : container-size-diff
154165 with :
@@ -170,7 +181,7 @@ jobs:
170181 show-summary : false
171182 push-to-registry : true
172183 - name : Verify attestation
184+ run : gh attestation verify --repo ${{ github.repository }} "oci://${REGISTRY}/${{ github.repository }}-${CONTAINER_FLAVOR}@${DIGEST}"
173185 env :
186+ DIGEST : ${{ steps.inspect-manifest.outputs.digest }}
174187 GH_TOKEN : ${{ github.token }}
175- run : |
176- gh attestation verify --repo ${{ github.repository }} oci://${{ env.REGISTRY }}/${{ github.repository }}-${{ inputs.flavor }}@${{ steps.inspect-manifest.outputs.digest }}
0 commit comments