Skip to content

Commit 483de10

Browse files
create a step to set the full OCI image URL in the github outputs
Signed-off-by: Nicolas-Peiffer <[email protected]>
1 parent 1122dfc commit 483de10

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

.github/workflows/base-container-build.yaml

+18-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
outputs:
3333
lowercase-github-repository: ${{ steps.convert.outputs.lowercase }}
3434
steps:
35-
- name: Convert repository name to lowercase
35+
- name: Convert GitHub repository name to lowercase for OCI registry
3636
id: convert
3737
run: |
3838
echo "lowercase=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
@@ -42,7 +42,7 @@ jobs:
4242
needs: set-lowercase-repository
4343
runs-on: ubuntu-latest
4444
steps:
45-
- name: Access lowercase repository name
45+
- name: Access lowercase GitHub repository name
4646
run: |
4747
echo "Original Repository: ${{ github.repository }}"
4848
echo "Lowercase Repository: ${{ needs.set-lowercase-repository.outputs.lowercase-github-repository }}"
@@ -87,12 +87,16 @@ jobs:
8787
username: ${{ github.actor }}
8888
password: ${{ secrets.GITHUB_TOKEN }}
8989

90+
- name: Set OCI container image URL to Github output
91+
id: set-oci-image-url
92+
run: echo "OCI_IMAGE_URL=${{ env.OCI_REGISTRY }}/${{ needs.set-lowercase-repository.outputs.lowercase-github-repository }}-base" >> $GITHUB_OUTPUT
93+
9094
- name: Container metadata and tags
9195
id: metadata
9296
uses: docker/metadata-action@v5
9397
with:
9498
# image name may contain lowercase letters, digits and separators https://github.com/docker/metadata-action/tree/v5/?tab=readme-ov-file#image-name-and-tag-sanitization
95-
images: ${{ env.OCI_REGISTRY }}/${{ needs.set-lowercase-repository.outputs.lowercase-github-repository }}-base
99+
images: ${{ steps.set-oci-image-url.outputs.oci_image_url }}
96100
tags: |
97101
type=ref,event=branch
98102
# use tools version as tags
@@ -115,7 +119,7 @@ jobs:
115119
# full length sha
116120
type=sha,format=long
117121
118-
- name: Build the OCI image (base image entrytoint /bin/bash)
122+
- name: Build the OCI image (base image entrypoint /bin/bash)
119123
id: kaniko
120124
uses: int128/kaniko-action@v1
121125
with:
@@ -130,11 +134,11 @@ jobs:
130134

131135
outputs:
132136
oci-image-digest: ${{ steps.kaniko.outputs.digest }}
133-
oci-image-url: ${{ steps.metadata.outputs.images }} # needs to be lowercase
137+
oci-image-url: ${{ steps.set-oci-image-url.outputs.oci_image_url }} # needs to be lowercase
134138

135139
# Job to build a SLSA provenance attestation
136140
base-image-provenance:
137-
name: Generate SLSA provenance attestation for OCI
141+
name: Generate SLSA provenance attestation for OCI (base image entrypoint /bin/bash)
138142
needs: [build-base-image, set-lowercase-repository] # Ensure this job runs after build-base-image
139143
permissions:
140144
actions: read # for detecting the Github Actions environment.
@@ -189,12 +193,16 @@ jobs:
189193
username: ${{ github.actor }}
190194
password: ${{ secrets.GITHUB_TOKEN }}
191195

196+
- name: Set OCI container image URL to Github output
197+
id: set-oci-image-url
198+
run: echo "OCI_IMAGE_URL=${{ env.OCI_REGISTRY }}/${{ needs.set-lowercase-repository.outputs.lowercase-github-repository }}" >> $GITHUB_OUTPUT
199+
192200
- name: Container metadata and tags
193201
id: metadata
194202
uses: docker/metadata-action@v5
195203
with:
196204
# image name may contain lowercase letters, digits and separators https://github.com/docker/metadata-action/tree/v5/?tab=readme-ov-file#image-name-and-tag-sanitization
197-
images: ${{ env.OCI_REGISTRY }}/${{ needs.set-lowercase-repository.outputs.lowercase-github-repository }}
205+
images: ${{ steps.set-oci-image-url.outputs.oci_image_url }}
198206
tags: |
199207
type=ref,event=branch
200208
# use tools version as tags
@@ -232,11 +240,11 @@ jobs:
232240

233241
outputs:
234242
oci-image-digest: ${{ steps.kaniko.outputs.digest }}
235-
oci-image-url: ${{ steps.metadata.outputs.images }} # needs to be lowercase
243+
oci-image-url: ${{ steps.set-oci-image-url.outputs.oci_image_url }} # needs to be lowercase
236244

237245
goreleaser-entryp-image-provenance:
238-
name: Generate SLSA provenance attestation for OCI
239-
needs: [build-goreleaser-entryp-image, set-lowercase-repository] # Ensure this job runs after build-base-image
246+
name: Generate SLSA provenance attestation for OCI (entrypoint goreleaser)
247+
needs: [build-goreleaser-entryp-image] # Ensure this job runs after build-base-image
240248
permissions:
241249
actions: read # for detecting the Github Actions environment.
242250
id-token: write # for creating OIDC tokens for signing. Required for SLSA and Cosign

0 commit comments

Comments
 (0)