Skip to content

Commit

Permalink
Docker: only write to cache if creds available
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed Jun 4, 2024
1 parent 0bc625f commit 73feaf5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/scripts/docker-build.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env bash
set -ex

# Only write to cache if credentials are available
if [[ -z "$DOCKERHUB_USERNAME" ]]; then
write_cache=""
else
write_cache="--cache-to=type=registry,ref=$DOCKERHUB_USERNAME/$IMAGE_NAME:$cache_tag,mode=max"
fi

DOCKERHUB_USERNAME="${DOCKERHUB_USERNAME:-conky}"
DOCKERHUB_IMAGE_ID=$DOCKERHUB_USERNAME/$IMAGE_NAME

Expand Down Expand Up @@ -41,6 +48,6 @@ docker buildx build \
${push_image} \
${image_platforms} \
--cache-from=type=registry,ref=$DOCKERHUB_USERNAME/$IMAGE_NAME:$cache_tag \
--cache-to=type=registry,ref=$DOCKERHUB_USERNAME/$IMAGE_NAME:$cache_tag,mode=max \
${write_cache} \
"${image_tags[@]}" \
.

0 comments on commit 73feaf5

Please sign in to comment.