Skip to content

Commit

Permalink
Trying to solve issues with push on docker multiplatform.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Nov 8, 2024
1 parent ae37af7 commit 04e0d73
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions .github/workflows/docker-hub-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,33 @@ jobs:
run: |
./docker-compose.sh platform
# - name: Generate images
# if: github.event_name != 'pull_request'
# run: |
# for tag in "deps" "dev" "runtime" "cli"; do
# mkdir -p "/tmp/images/${tag}"
# digest="$(docker images --no-trunc --quiet metacall/core:${tag})"
# echo "FROM metacall/core:${tag}@${digest}" &> "/tmp/images/${tag}/Dockerfile"
# done

# - name: Build and push by digest (deps)
# id: build
# uses: docker/build-push-action@v6
# if: github.event_name != 'pull_request'
# with:
# context: /tmp/images/deps/Dockerfile
# platforms: ${{ matrix.platform }}
# labels: ${{ steps.meta.outputs.labels }}
# outputs: type=image,name=docker.io/${{ env.IMAGE_NAME }}:deps,push-by-digest=true,name-canonical=true,push=true

- name: Export digests
if: github.event_name != 'pull_request'
run: |
PLATFORM=${{ matrix.platform }}
echo "PLATFORM=${PLATFORM//\//-}" >> $GITHUB_ENV
for tag in "deps" "dev" "runtime" "cli"; do
mkdir -p "/tmp/digests/${tag}"
digest="$(docker images --no-trunc --quiet metacall/core:$tag)"
digest="$(docker images --no-trunc --quiet metacall/core:${tag})"
touch "/tmp/digests/${tag}/${digest#sha256:}"
done
Expand Down Expand Up @@ -128,17 +147,18 @@ jobs:
run: |
for tag in "deps" "dev" "runtime" "cli"; do
cd "/tmp/digests/${tag}"
IMAGE_HASHES=$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
for image in $IMAGE_HASHES; do
docker push $image
IMAGE_HASHES=$(printf '${{ env.IMAGE_NAME }}:${tag}@sha256:%s ' *)
for image in ${IMAGE_HASHES}; do
docker image tag ${image} ${{ env.IMAGE_NAME }}:${tag}
docker push ${{ env.IMAGE_NAME }}:${tag}
done
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:$tag $IMAGE_HASHES
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${tag} ${IMAGE_HASHES}
if [[ "${tag}" = "cli" ]]; then
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:latest $IMAGE_HASHES
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:latest ${IMAGE_HASHES}
if [[ "${{ contains(github.ref, 'refs/tags/') }}" = true ]]; then
TAG=${GITHUB_REF#refs/*/}
VERSION=${TAG#v}
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:$VERSION $IMAGE_HASHES
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${VERSION} ${IMAGE_HASHES}
fi
fi
done

0 comments on commit 04e0d73

Please sign in to comment.