Skip to content

Commit 4437b2b

Browse files
author
F嘉阳-coder
committed
fix: use lowercase image name for GHCR compatibility
1 parent 35420dd commit 4437b2b

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

.github/workflows/build-and-push.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jobs:
3232
PLATFORM_PAIR=$(echo ${{ matrix.platform }} | tr '/' '-')
3333
echo "PLATFORM_PAIR=$PLATFORM_PAIR" >> $GITHUB_ENV
3434
35+
- name: Set lowercase image name
36+
run: |
37+
echo "IMAGE_NAME=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
38+
3539
- name: Set up Docker Buildx
3640
uses: docker/setup-buildx-action@v3
3741

@@ -46,7 +50,7 @@ jobs:
4650
id: meta
4751
uses: docker/metadata-action@v5
4852
with:
49-
images: ghcr.io/${{ github.repository }}
53+
images: ${{ env.IMAGE_NAME }}
5054
tags: |
5155
type=raw,value=latest,enable={{is_default_branch}}
5256
type=sha,format=short
@@ -59,7 +63,7 @@ jobs:
5963
context: .
6064
platforms: ${{ matrix.platform }}
6165
labels: ${{ steps.meta.outputs.labels }}
62-
outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
66+
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
6367
cache-from: type=gha,scope=${{ matrix.platform }}
6468
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
6569

@@ -92,6 +96,10 @@ jobs:
9296
- name: Get current date for tagging
9397
run: echo "DATE_TAG=$(date +'%Y%m%d')" >> $GITHUB_ENV
9498

99+
- name: Set lowercase image name
100+
run: |
101+
echo "IMAGE_NAME=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
102+
95103
- name: Set up Docker Buildx
96104
uses: docker/setup-buildx-action@v3
97105

@@ -113,7 +121,7 @@ jobs:
113121
id: meta
114122
uses: docker/metadata-action@v5
115123
with:
116-
images: ghcr.io/${{ github.repository }}
124+
images: ${{ env.IMAGE_NAME }}
117125
tags: |
118126
type=raw,value=latest,enable={{is_default_branch}}
119127
type=sha,format=short
@@ -125,7 +133,7 @@ jobs:
125133
# Build the list of digests
126134
digests=$(find . -type f -name "*-*" | while read f; do
127135
digest=$(basename "$f" | sed 's/^[^-]*-//')
128-
echo "ghcr.io/${{ github.repository }}@sha256:${digest}"
136+
echo "${{ env.IMAGE_NAME }}@sha256:${digest}"
129137
done)
130138
131139
# Create and push manifest with all tags
@@ -136,4 +144,4 @@ jobs:
136144
- name: Inspect image
137145
run: |
138146
TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1 | cut -d':' -f2)
139-
docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${TAG}
147+
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${TAG}

0 commit comments

Comments
 (0)