Skip to content

Commit 31b9be7

Browse files
committed
ci: normalize Docker image name to lowercase to comply with OCI naming rules
1 parent 769628b commit 31b9be7

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/build-and-publish-docker-image.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ permissions:
1515
# Reusable values available to all jobs/steps
1616
env:
1717
REGISTRY: ghcr.io
18-
IMAGE_NAME: ${{ github.repository }} # e.g. owner/repo
18+
IMAGE_NAME: ${{ github.repository }} # e.g. owner/repo (may be mixed-case)
1919

2020
jobs:
2121
build-and-push:
@@ -67,12 +67,16 @@ jobs:
6767
run: |
6868
echo "::group::Compute image reference and tags"
6969
# Compose the full image reference and tag set
70-
IMAGE_REF=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
70+
# Lowercase the owner/repo to satisfy Docker/OCI naming rules
71+
IMAGE_NAME_LOWER=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
72+
IMAGE_REF=${{ env.REGISTRY }}/${IMAGE_NAME_LOWER}
7173
MAJOR=${{ steps.version.outputs.major }}
7274
MINOR=${{ steps.version.outputs.minor }}
7375
PATCH=${{ steps.version.outputs.patch }}
7476
VERSION=${{ steps.version.outputs.version }}
7577
78+
echo "Original IMAGE_NAME: ${{ env.IMAGE_NAME }}"
79+
echo "Normalized (lowercase) IMAGE_NAME: ${IMAGE_NAME_LOWER}"
7680
echo "Image reference: ${IMAGE_REF}"
7781
echo "Using version parts => MAJOR=${MAJOR}, MINOR=${MINOR}, PATCH=${PATCH}"
7882
@@ -89,6 +93,9 @@ jobs:
8993
# Join tags with comma for build-push-action
9094
TAGS_CSV=$(IFS=, ; echo "${TAGS[*]}")
9195
echo "tags=$TAGS_CSV" >> $GITHUB_OUTPUT
96+
# Also expose normalized values for later steps
97+
echo "image_name_lower=${IMAGE_NAME_LOWER}" >> $GITHUB_OUTPUT
98+
echo "image_ref=${IMAGE_REF}" >> $GITHUB_OUTPUT
9299
echo "Computed tags CSV: ${TAGS_CSV}"
93100
echo "::endgroup::"
94101
@@ -106,15 +113,15 @@ jobs:
106113
org.opencontainers.image.revision=${{ github.sha }}
107114
org.opencontainers.image.version=${{ steps.version.outputs.version }}
108115
# Enable build cache stored in GHCR for faster rebuilds
109-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
110-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
116+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.meta.outputs.image_name_lower }}:buildcache
117+
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.meta.outputs.image_name_lower }}:buildcache,mode=max
111118

112119
- name: Summarize publish details
113120
if: always()
114121
shell: bash
115122
run: |
116123
echo "## Docker Image Publish Summary" >> "$GITHUB_STEP_SUMMARY"
117-
echo "Repository: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> "$GITHUB_STEP_SUMMARY"
124+
echo "Repository: ${{ env.REGISTRY }}/${{ steps.meta.outputs.image_name_lower }}" >> "$GITHUB_STEP_SUMMARY"
118125
echo "Version: ${{ steps.version.outputs.version }}" >> "$GITHUB_STEP_SUMMARY"
119126
echo "Tags pushed:" >> "$GITHUB_STEP_SUMMARY"
120127
IFS=',' read -ra TAGS_ARR <<< "${{ steps.meta.outputs.tags }}"

0 commit comments

Comments
 (0)