Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! Cache Docker images on GitHub container r…
Browse files Browse the repository at this point in the history
…egistry
  • Loading branch information
TheAssassin committed Dec 25, 2024
1 parent 5408b1f commit 634ada3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ci/build-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,23 @@ repo_root="$(readlink -f "$(dirname "$0")"/..)"
# use docker image tag provided by GitHub actions if possible
DOCKER_TAG="${DOCKER_TAG:-ghcr.io/appimage/appimageupdate-build:local-build}"

default_branch_tag="$(echo "$DOCKER_TAG" | cut -d: -f1):$(echo "$GITHUB_DEFAULT_BRANCH" | rev | cut -d/ -f1 | rev)"
default_branch_tag="$(echo "$DOCKER_TAG" | cut -d: -f1):$(echo "${GITHUB_DEFAULT_BRANCH:-main}" | rev | cut -d/ -f1 | rev)"

extra_build_args=()

if [[ "${GITHUB_ACTIONS:-}" != "" ]]; then
echo "Building on GitHub actions, pushing cache"
extra_build_args+=(
--output "type=registry,ref=${DOCKER_TAG}"
--push
)
else
echo "Local build, not pushing cache"
fi

# building local image to "cache" installed dependencies for subsequent builds
docker build \
--cache-to inline \
docker buildx build \
"${extra_build_args[@]}" \
--cache-from "type=registry,ref=${DOCKER_TAG}" \
--cache-from "type=registry,ref=${default_branch_tag}" \
--platform "$docker_platform" \
Expand Down

0 comments on commit 634ada3

Please sign in to comment.