Skip to content

Commit 0a10c7e

Browse files
Fixed logic error for manual triggers
1 parent 009c60f commit 0a10c7e

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

.github/workflows/docker-image-build-release.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ jobs:
2121
- name: Set repo name to lowercase
2222
run: echo "LOWER_REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
2323

24+
- name: Determine Version
25+
run: |
26+
# If triggered by a release, use the tag (e.g., v1.0.0)
27+
if [ -n "${{ github.event.release.tag_name }}" ]; then
28+
echo "VERSION_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
29+
else
30+
# If triggered manually, fallback to avoid build failure
31+
echo "VERSION_TAG=manual-build" >> $GITHUB_ENV
32+
fi
33+
2434
# --- 2. Logins ---
2535
- name: DockerHub Login
2636
uses: docker/login-action@v3
@@ -54,7 +64,7 @@ jobs:
5464
type=image,name=ghcr.io/${{ github.repository_owner }}/${{ env.LOWER_REPO_NAME }},push-by-digest=true,name-canonical=true,push=true
5565
build-args: |
5666
BUILD_DATE=${{ github.event.repository.updated_at }}
57-
VERSION=${{ github.event.release.tag_name }}
67+
VERSION=${{ env.VERSION_TAG }}
5868
5969
# --- 4. Export Digest ---
6070
- name: Export digest
@@ -85,6 +95,14 @@ jobs:
8595
- name: Set repo name to lowercase
8696
run: echo "LOWER_REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
8797

98+
- name: Determine Version
99+
run: |
100+
if [ -n "${{ github.event.release.tag_name }}" ]; then
101+
echo "VERSION_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
102+
else
103+
echo "VERSION_TAG=manual-build" >> $GITHUB_ENV
104+
fi
105+
88106
# --- 2. Logins ---
89107
- name: DockerHub Login
90108
uses: docker/login-action@v3
@@ -110,14 +128,15 @@ jobs:
110128
context: .
111129
platforms: linux/arm64
112130
# CACHE STRATEGY: Use Local Disk Cache (Persistent Oracle Runner)
131+
# Reuses the same cache folder as your DEV builds for speed
113132
cache-from: type=local,src=/tmp/.buildx-cache
114133
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
115134
outputs: |
116135
type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated,push-by-digest=true,name-canonical=true,push=true
117136
type=image,name=ghcr.io/${{ github.repository_owner }}/${{ env.LOWER_REPO_NAME }},push-by-digest=true,name-canonical=true,push=true
118137
build-args: |
119138
BUILD_DATE=${{ github.event.repository.updated_at }}
120-
VERSION=${{ github.event.release.tag_name }}
139+
VERSION=${{ env.VERSION_TAG }}
121140
122141
# --- 4. Rotate Cache (Prevent Infinite Growth) ---
123142
- name: Move cache
@@ -167,10 +186,9 @@ jobs:
167186
id: tag
168187
run: |
169188
# Use the Release Tag (e.g., v3.0.0)
170-
echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
171-
172-
# Fallback if workflow_dispatch was used (manual trigger)
173-
if [ -z "${{ github.event.release.tag_name }}" ]; then
189+
if [ -n "${{ github.event.release.tag_name }}" ]; then
190+
echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
191+
else
174192
echo "RELEASE_TAG=manual-build" >> $GITHUB_ENV
175193
fi
176194

0 commit comments

Comments
 (0)