Skip to content

Commit 4e50046

Browse files
authored
Merge pull request #1728 from yiannistri/1723-image-digest
ci: Use digests instead of tags when signing images
2 parents 81701f9 + b27945d commit 4e50046

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

.github/workflows/release-v2.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
secret/data/github/repo/${{ github.repository }}/rancher-prime-stg-registry/credentials username | STAGING_REGISTRY_USERNAME ;
9999
secret/data/github/repo/${{ github.repository }}/rancher-prime-stg-registry/credentials password | STAGING_REGISTRY_PASSWORD ;
100100
secret/data/github/repo/${{ github.repository }}/rancher-prime-registry/credentials registry | PRIME_REGISTRY ;
101-
101+
102102
- name: Log into Docker Hub registry
103103
if: ${{ matrix.image-type == 'community' }}
104104
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3
@@ -118,7 +118,7 @@ jobs:
118118
if: ${{ matrix.image-type == 'prime' }}
119119
uses: sigstore/cosign-installer@d7543c93d881b35a8faa02e8e3605f69b7a1ce62 # v3.10.0
120120

121-
- name: Create multi-arch image and push
121+
- name: Create multi-platform image and push
122122
shell: bash
123123
run: |
124124
IMAGE="turtles"
@@ -127,19 +127,27 @@ jobs:
127127
docker buildx imagetools create -t "${URL}" \
128128
"${URL}-linux-amd64" \
129129
"${URL}-linux-arm64"
130-
else
130+
echo "Pushed multi-platform image: ${URL}"
131+
elif [ "${{ matrix.image-type }}" = "prime" ]; then
131132
URL="${{ env.STAGING_REGISTRY }}/rancher/${IMAGE}:${{ env.TAG }}"
132133
docker buildx imagetools create -t "${URL}" \
133134
"${URL}-linux-amd64" \
134135
"${URL}-linux-arm64"
136+
echo "Pushed multi-platform image: ${URL}"
137+
138+
# Extract the multi-platform image digest for signing
139+
docker pull ${URL}
140+
IMAGE_DIGEST=$( docker inspect --format='{{index .RepoDigests 0}}' ${URL} | sed 's/.*@//' )
141+
echo "IMAGE_DIGEST=${IMAGE_DIGEST}" >> "$GITHUB_ENV"
135142
fi
136143
137-
- name: Sign multi-arch image
144+
- name: Sign multi-platform image
138145
shell: bash
139146
if: ${{ matrix.image-type == 'prime' }}
140147
run: |
141-
IMAGE="turtles"
142-
URL="${{ env.STAGING_REGISTRY }}/rancher/${IMAGE}:${{ env.TAG }}"
148+
IMAGE="turtles"
149+
URL="${{ env.STAGING_REGISTRY }}/rancher/${IMAGE}@${IMAGE_DIGEST}"
150+
143151
cosign sign \
144152
--oidc-provider=github-actions \
145153
--yes \

0 commit comments

Comments
 (0)