From 0f42b1752c573817fd275fb7c7c40c0640c819da Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Thu, 26 Dec 2024 01:29:27 +0100 Subject: [PATCH] fixup! fixup! fixup! fixup! fixup! Cache Docker images on GitHub container registry --- .github/workflows/main.yml | 2 -- ci/build-in-docker.sh | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e06ab32..2239950 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,8 +35,6 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build AppImage in Docker run: bash -ex ci/build-in-docker.sh - env: - DOCKER_TAG: ${{ steps.meta.outputs.tags[0] }} - name: Archive artifacts uses: actions/upload-artifact@v4 with: diff --git a/ci/build-in-docker.sh b/ci/build-in-docker.sh index 12774b8..be4d5e4 100755 --- a/ci/build-in-docker.sh +++ b/ci/build-in-docker.sh @@ -32,16 +32,16 @@ cwd="$PWD" 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}" +docker_tag="ghcr.io/appimagecommunity/appimageupdate-build:$(cut -d: -f2- <<<"${DOCKER_METADATA_OUTPUT_TAGS:-:local-build}")" -default_branch_tag="$(echo "$DOCKER_TAG" | cut -d: -f1):$(echo "${GITHUB_DEFAULT_BRANCH:-main}" | rev | cut -d/ -f1 | rev)" +default_branch_tag="$(cut -d: -f1 <<<"$docker_tag"):$(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}" + --output "type=registry,ref=${docker_tag}" --push ) else @@ -51,10 +51,10 @@ fi # building local image to "cache" installed dependencies for subsequent builds docker buildx build \ "${extra_build_args[@]}" \ - --cache-from "type=registry,ref=${DOCKER_TAG}" \ + --cache-from "type=registry,ref=${docker_tag}" \ --cache-from "type=registry,ref=${default_branch_tag}" \ --platform "$docker_platform" \ - -t "$DOCKER_TAG" \ + -t "$docker_tag" \ --build-arg ARCH="$ARCH" \ --build-arg CMAKE_ARCH="$CMAKE_ARCH" \ "$repo_root"/ci @@ -80,5 +80,5 @@ docker run \ -v "$cwd":/out \ -w /out \ --user "$uid" \ - "$DOCKER_TAG" \ + "$docker_tag" \ bash /ws/ci/build-appimages.sh