Skip to content

Commit

Permalink
Explicitly downcase image ref
Browse files Browse the repository at this point in the history
This is handled by docker/metadata-action for the generated tags,
but env.IMAGE was also used directly, causing errors if the owner or
repo name contained any mixed case
  • Loading branch information
Orochimarufan authored and anatol committed Nov 17, 2023
1 parent f8fb556 commit 64131af
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ jobs:
steps:
- uses: actions/checkout@v3

# Spec requires ref to be lowercase, but
# user/org/repo name may have mixed case
- name: Sanitize image ref
uses: ASzc/change-string-case-action@v6
id: ref
with:
string: ${{ env.REGISTRY }}/${{ env.IMAGE }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand All @@ -105,7 +113,7 @@ jobs:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
outputs: type=image,name=${{ steps.ref.outputs.lowercase }},push-by-digest=true,name-canonical=true,push=true
# Enable cache to speed up builds
# Scope is to ensure that images don't overwrite each other's cache
cache-from: type=gha,scope=${{ env.REGISTRY }}-${{ github.ref_name }}-${{ matrix.platform }}-executable
Expand Down Expand Up @@ -142,6 +150,14 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Spec requires ref to be lowercase, but
# user/org/repo name may have mixed case
- name: Sanitize image ref
uses: ASzc/change-string-case-action@v6
id: ref
with:
string: ${{ env.REGISTRY }}/${{ env.IMAGE }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand All @@ -167,8 +183,8 @@ jobs:
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE }}@sha256:%s ' *)
$(printf '${{ steps.ref.outputs.lowercase }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ steps.ref.outputs.lowercase }}:${{ steps.meta.outputs.version }}

0 comments on commit 64131af

Please sign in to comment.