Skip to content

Commit

Permalink
ci: fix matrix docker-build
Browse files Browse the repository at this point in the history
  • Loading branch information
DrummyFloyd committed Jan 7, 2025
1 parent c3113d3 commit aa62599
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/docker-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,23 @@ on:
description: "The highest-priority tag assigned to the built image"
value: ${{ jobs.docker.outputs.image_tag }}

env:
AMD64_RUNNER: "ubuntu-latest"
ARM64_RUNNER: "ARM64"

jobs:
# First, create a job to set up the matrix
prepare:
runs-on: ubuntu-latest
outputs:
platforms: ${{ steps.set-platforms.outputs.platforms }}
steps:
- id: set-platforms
run: |
platforms=$(echo "${{ inputs.platforms }}" | tr ',' '\n' | jq -R -s -c 'split("\n")[:-1]')
echo "platforms=${platforms}" >> $GITHUB_OUTPUT
docker:
needs: prepare
runs-on: ${{ contains(matrix.platform, 'arm64') && ARM64 || ubuntu-latest }}
strategy:
matrix:
platform:
- ${{ fromJSON(format('[{0}]', join(split(inputs.platforms, ','), '},{'))) }}
runs-on: ${{ contains(matrix.platform, 'arm64') && env.ARM64_RUNNER || env.AMD64_RUNNER }}
platform: ${{ fromJson(needs.prepare.outputs.platforms) }}

outputs:
image_tag: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
Expand Down Expand Up @@ -192,7 +198,7 @@ jobs:
retention-days: 1
merge:
runs-on: ubuntu-latest
needs: [docker_buil]
needs: [docker_build]
steps:
- name: Download digests
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -233,9 +239,9 @@ jobs:
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ docker.steps.prep.outputs.images }}@sha256:%s ' *)
$(printf '${{ jobs.docker.steps.prep.outputs.images }}@sha256:%s ' *)
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ docker.steps.prep.outputs.cache_to }}@sha256:%s ' *)
$(printf '${{ jobs.docker.steps.prep.outputs.cache_to }}@sha256:%s ' *)
# - name: Inspect image
# run: |
Expand Down

0 comments on commit aa62599

Please sign in to comment.