Skip to content

Commit ed9694b

Browse files
authored
docker-publish-fix5
1 parent c6aada3 commit ed9694b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

.github/workflows/docker-publish.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
version:
99
description: 'Version tag for the Docker image'
1010
required: true
11-
default: 'latest' # You can set a default version if desired
11+
default: 'latest'
1212

1313
jobs:
1414
build-and-push:
@@ -37,12 +37,19 @@ jobs:
3737
username: ${{ secrets.DOCKERHUB_USER }}
3838
password: ${{ secrets.DOCKERHUB_AT }}
3939

40-
- name: Use version input
40+
- name: Determine version
4141
id: use_version
4242
run: |
43-
VERSION="${{ github.event.inputs.version }}"
43+
# If the workflow is triggered by a release, use the release tag
44+
if [ "${GITHUB_EVENT_NAME}" == "release" ]; then
45+
VERSION="${GITHUB_REF#refs/tags/}"
46+
else
47+
VERSION="${{ github.event.inputs.version }}"
48+
fi
4449
VERSION_LOWER=$(echo $VERSION | tr '[:upper:]' '[:lower:]')
50+
REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
4551
echo "VERSION=$VERSION_LOWER" >> $GITHUB_ENV
52+
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
4653
4754
- name: Retrieve previous release version
4855
id: previous_version
@@ -61,8 +68,8 @@ jobs:
6168
- name: Build and Push Docker Image (GitHub Packages)
6269
run: |
6370
docker buildx build --platform linux/amd64,linux/arm64 \
64-
--tag ghcr.io/${{ github.repository }}:${{ env.VERSION }} \
65-
--tag ghcr.io/${{ github.repository }}:latest \
71+
--tag ghcr.io/${{ env.REPO_NAME }}:${{ env.VERSION }} \
72+
--tag ghcr.io/${{ env.REPO_NAME }}:latest \
6673
--push .
6774
6875
- name: Build and Push Docker Image (DockerHub)

0 commit comments

Comments
 (0)