Skip to content

Commit 1ca0e01

Browse files
tonyxiaoclaude
andcommitted
Fix Docker tag: sanitize ref_name to replace / with -
On PR events github.ref_name is '142/merge' — slashes are invalid in Docker image tags. Replace / with - before using as a tag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
1 parent d181dc7 commit 1ca0e01

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,24 @@ jobs:
5151
username: ${{ github.actor }}
5252
password: ${{ secrets.GITHUB_TOKEN }}
5353

54+
- name: Sanitize Docker tag
55+
id: tag
56+
run: echo "value=$(echo '${{ github.ref_name }}' | sed 's/\//-/g')" >> $GITHUB_OUTPUT
57+
5458
- name: Build Docker image
5559
run: |
5660
docker build \
5761
--build-arg GIT_COMMIT=${{ github.sha }} \
5862
--build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
5963
--build-arg COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} \
6064
-t ghcr.io/${{ github.repository }}:${{ github.sha }} \
61-
-t ghcr.io/${{ github.repository }}:${{ github.ref_name }} \
65+
-t ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.value }} \
6266
.
6367
6468
- name: Push Docker image
6569
run: |
6670
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
67-
docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }}
71+
docker push ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.value }}
6872
6973
- name: Docker smoke test
7074
run: docker run --rm ghcr.io/${{ github.repository }}:${{ github.sha }} --version

0 commit comments

Comments
 (0)