Skip to content

Commit b9cb215

Browse files
committed
Attest with name containing the registry
Build gives "Error: Invalid image name". I believe it is because the registry is missing in the container name. The CPU version still had "-" suffix.
1 parent f4d3c0c commit b9cb215

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

.github/workflows/main.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
# Tags have limited set of valid character, '+' not included
5959
# https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests
6060
run: |
61-
echo "tag=$(echo -n "${{ matrix.torch }}${{ matrix.index && format('-{0}', matrix.index) || '' }}-${{ matrix.python }}${PLATFORM+-}${PLATFORM#*/}" | tr -c 'a-zA-Z0-9._-' '[-*]')" >> $GITHUB_OUTPUT
61+
echo "tag=$(echo -n "${{ matrix.torch }}${{ matrix.index && format('-{0}', matrix.index) || '' }}-${{ matrix.python }}${PLATFORM:+-}${PLATFORM#*/}" | tr -c 'a-zA-Z0-9._-' '[-*]')" >> $GITHUB_OUTPUT
6262
env:
6363
PLATFORM: ${{ matrix.index != 'cpu' && matrix.platform || '' }}
6464

@@ -88,7 +88,7 @@ jobs:
8888
- name: Create attestation for the image
8989
uses: actions/attest-build-provenance@v3
9090
with:
91-
subject-name: ${{ vars.DOCKERHUB_USERNAME }}/python-torch:${{ steps.build-tag.outputs.tag }}
91+
subject-name: docker.io/${{ vars.DOCKERHUB_USERNAME }}/python-torch:${{ steps.build-tag.outputs.tag }}
9292
subject-digest: ${{ steps.build-push.outputs.digest }}
9393
push-to-registry: true
9494

@@ -117,18 +117,19 @@ jobs:
117117
# This must match the build job tag generation
118118
tag="$(echo -n "${{ matrix.torch }}${{ matrix.index && format('-{0}', matrix.index) || '' }}-${{ matrix.python }}" | tr -c 'a-zA-Z0-9._-' '[-*]')"
119119
echo "tag=${tag}" >> $GITHUB_OUTPUT
120-
name="$DOCKERHUB_USERNAME/python-torch:${tag}"
120+
repository="docker.io/$DOCKERHUB_USERNAME/python-torch"
121+
name="$repository:$tag"
121122
echo "name=${name}" >> $GITHUB_OUTPUT
122123
docker buildx imagetools create \
123124
--tag $name \
124125
${name}-amd64 \
125126
${name}-arm64
126-
# Unfortunately we don't get the digest directly so we need to query it
127+
# Unfortunately we don't get the digest directly so we need to query it risking it get changed
127128
DIGEST=$(docker buildx imagetools inspect "${name}" --format '{{ print .Manifest.Digest }}')
128129
# Ensure the images bundled behind the digest about to be attested still have valid attestations
129-
for digest in $(docker buildx imagetools inspect "$DOCKERHUB_USERNAME/python-torch@$DIGEST" --format '{{ range .Manifest.Manifests }}{{ .Digest }} {{ end }}')
130+
for digest in $(docker buildx imagetools inspect "$repository@$DIGEST" --format '{{ range .Manifest.Manifests }}{{ .Digest }} {{ end }}')
130131
do
131-
gh attestation verify oci://$DOCKERHUB_USERNAME/python-torch@${digest} \
132+
gh attestation verify oci://$repository@$digest \
132133
--repo $GITHUB_REPOSITORY \
133134
--signer-workflow $GITHUB_WORKFLOW_REF \
134135
--source-digest $GITHUB_SHA

0 commit comments

Comments
 (0)