Updating cache action

This commit is contained in:
2024-12-06 08:50:10 +01:00
parent 9fd6055579
commit 354f5cdadc

View File

@@ -37,9 +37,10 @@ if [ "$INPUT_PUSH_IMAGE" = "true" ]; then
fi
if [ "$INPUT_PULL_CACHE" = "true" ]; then
DOCKER_BUILD_OPTIONS+=("--cache-from" "$IMAGE_NAME")
echo "Pulling for cache"
docker pull "$IMAGE_NAME" || echo "Unable to find an image to pull."
IMAGE_CACHE_NAME="${IMAGE_NAME%%:*}:build-cache"
DOCKER_BUILD_OPTIONS+=("--cache-from" "type=registry,ref=${IMAGE_CACHE_NAME}")
DOCKER_BUILD_OPTIONS+=("--cache-to" "type=registry,ref=${IMAGE_CACHE_NAME},mode=max")
echo "Using docker image cache ${IMAGE_CACHE_NAME}"
fi
DOCKER_BUILD_OPTIONS+=("${INPUT_DOCKERFILE_PATH}")
@@ -48,6 +49,8 @@ echo "Running docker buildx with options: ${DOCKER_BUILD_OPTIONS[@]}"
echo "Building and pushing !"
docker buildx build "${DOCKER_BUILD_OPTIONS[@]}"
echo "Cleaning up docker"
docker system prune --force
echo "imageName=${IMAGE_NAME}" >>"$GITEA_OUTPUT"