Skip to content

Commit 5ce385d

Browse files
Made it so that old dev builds are now still available with a image tag with dev-<build-no>
1 parent 9592cb7 commit 5ce385d

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
provenance: false
7070
context: .
7171
file: ./Dockerfile
72-
# We build only AMD64 here
72+
# We build AMD64 here natively
7373
platforms: linux/amd64
7474
# CACHE STRATEGY: Use GitHub Actions Cache (Ephemeral Runner)
7575
cache-from: type=gha
@@ -183,7 +183,7 @@ jobs:
183183

184184
# --- 6. Janitor: Clean up Docker Garbage ---
185185
- name: Prune Docker Garbage
186-
if: always() # Run even if build fails
186+
if: always() # Run even if build fails to keep disk clean
187187
run: |
188188
echo "Pruning dangling images..."
189189
docker image prune -f
@@ -207,15 +207,21 @@ jobs:
207207
- name: Set repo name to lowercase
208208
run: echo "LOWER_REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
209209

210-
- name: Determine Docker Image Tag
210+
- name: Determine Docker Image Tags
211211
id: tag
212212
run: |
213+
# 1. Determine the "Floating" Tag (e.g., 'dev' or 'dev-featurebranch')
213214
if [[ "${{ github.ref_name }}" == "main" ]]; then
214-
echo "IMAGE_TAG=dev" >> $GITHUB_ENV
215+
echo "FLOAT_TAG=dev" >> $GITHUB_ENV
215216
else
216217
sanitized_branch=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9.-]/-/g')
217-
echo "IMAGE_TAG=dev-${sanitized_branch}" >> $GITHUB_ENV
218+
echo "FLOAT_TAG=dev-${sanitized_branch}" >> $GITHUB_ENV
218219
fi
220+
221+
# 2. Determine the "Unique" Tag (e.g., 'dev-371')
222+
# We use the build number that was passed to the build jobs
223+
# Note: We append the build number to the 'dev' prefix to keep them grouped
224+
echo "UNIQUE_TAG=dev-${{ vars.CURRENT_DEV_BUILD_NUM }}" >> $GITHUB_ENV
219225
220226
# --- 2. Logins ---
221227
- name: DockerHub Login
@@ -245,12 +251,16 @@ jobs:
245251
- name: Create manifest list and push
246252
working-directory: /tmp/digests
247253
run: |
248-
# 1. Create/Push Manifest for DockerHub
249-
docker buildx imagetools create -t ${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated:${{ env.IMAGE_TAG }} \
254+
# 1. Push to DockerHub (Both Tags)
255+
docker buildx imagetools create \
256+
-t ${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated:${{ env.FLOAT_TAG }} \
257+
-t ${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated:${{ env.UNIQUE_TAG }} \
250258
$(printf '${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated@sha256:%s ' *)
251259
252-
# 2. Create/Push Manifest for GHCR
253-
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/${{ env.LOWER_REPO_NAME }}:${{ env.IMAGE_TAG }} \
260+
# 2. Push to GHCR (Both Tags)
261+
docker buildx imagetools create \
262+
-t ghcr.io/${{ github.repository_owner }}/${{ env.LOWER_REPO_NAME }}:${{ env.FLOAT_TAG }} \
263+
-t ghcr.io/${{ github.repository_owner }}/${{ env.LOWER_REPO_NAME }}:${{ env.UNIQUE_TAG }} \
254264
$(printf 'ghcr.io/${{ github.repository_owner }}/${{ env.LOWER_REPO_NAME }}@sha256:%s ' *)
255265
256266
# --- 4. Increment Build Number (Last Step) ---

0 commit comments

Comments
 (0)