Skip to content

Commit 4fbcd0b

Browse files
Merge pull request #231 from IABTechLab/bmz-UID2-7041-retag-promotion
UID2-7041: promote OCI tag only after attest+verify pass
2 parents 59602cb + b05c09b commit 4fbcd0b

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

.github/workflows/shared-publish-java-to-docker-versioned.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,13 @@ jobs:
209209
image_ref: ${{ steps.extractImageTag.outputs.firstTag }}
210210
scan_type: image
211211

212-
- name: Push to Docker
212+
- name: Push to Docker (by digest, untagged)
213213
id: push
214214
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
215215
with:
216216
context: ${{inputs.working_dir}}
217-
push: true
218-
tags: ${{ steps.meta.outputs.tags }}
219217
labels: ${{ steps.meta.outputs.labels }}
218+
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ inputs.append_image_name }},push-by-digest=true,push=true
220219
build-args: |
221220
JAR_VERSION=${{ steps.version.outputs.new_version }}
222221
IMAGE_VERSION=${{ steps.version.outputs.new_version }}
@@ -228,6 +227,19 @@ jobs:
228227
subject_name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ inputs.append_image_name }}
229228
subject_digest: ${{ steps.push.outputs.digest }}
230229

230+
- name: Promote digest to consumable tag(s)
231+
shell: bash
232+
env:
233+
DIGEST: ${{ steps.push.outputs.digest }}
234+
TAGS: ${{ steps.meta.outputs.tags }}
235+
SOURCE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ inputs.append_image_name }}
236+
run: |
237+
set -euo pipefail
238+
while IFS= read -r tag; do
239+
[[ -z "$tag" ]] && continue
240+
docker buildx imagetools create -t "$tag" "${SOURCE}@${DIGEST}"
241+
done <<< "$TAGS"
242+
231243
- name: Create Release
232244
uses: IABTechLab/uid2-shared-actions/actions/shared_create_releases@v3
233245
with:

actions/shared_publish_to_docker/action.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,14 @@ runs:
9292
image_ref: ${{ steps.extractImageTag.outputs.firstTag }}
9393
scan_type: ${{ inputs.scan_type }}
9494

95-
- name: Push to Docker
95+
- name: Push to Docker (by digest, untagged)
9696
id: push
9797
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
9898
with:
9999
context: ${{ inputs.docker_context }}
100100
file: ${{ inputs.docker_file }}
101-
push: true
102-
tags: ${{ steps.meta.outputs.tags }}
103101
labels: ${{ steps.meta.outputs.labels }}
102+
outputs: type=image,name=${{ inputs.docker_registry }}/${{ inputs.docker_image_name }},push-by-digest=true,push=true
104103
build-args: |
105104
JAR_VERSION=${{ inputs.new_version }}
106105
IMAGE_VERSION=${{ inputs.new_version }}
@@ -111,3 +110,16 @@ runs:
111110
with:
112111
subject_name: ${{ inputs.docker_registry }}/${{ inputs.docker_image_name }}
113112
subject_digest: ${{ steps.push.outputs.digest }}
113+
114+
- name: Promote digest to consumable tag(s)
115+
shell: bash
116+
env:
117+
DIGEST: ${{ steps.push.outputs.digest }}
118+
TAGS: ${{ steps.meta.outputs.tags }}
119+
SOURCE: ${{ inputs.docker_registry }}/${{ inputs.docker_image_name }}
120+
run: |
121+
set -euo pipefail
122+
while IFS= read -r tag; do
123+
[[ -z "$tag" ]] && continue
124+
docker buildx imagetools create -t "$tag" "${SOURCE}@${DIGEST}"
125+
done <<< "$TAGS"

0 commit comments

Comments
 (0)