Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! Cache Docker images on GitHub cont…
Browse files Browse the repository at this point in the history
…ainer registry
  • Loading branch information
TheAssassin committed Dec 26, 2024
1 parent 634ada3 commit 0f42b17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions ci/build-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -80,5 +80,5 @@ docker run \
-v "$cwd":/out \
-w /out \
--user "$uid" \
"$DOCKER_TAG" \
"$docker_tag" \
bash /ws/ci/build-appimages.sh

0 comments on commit 0f42b17

Please sign in to comment.