Skip to content

Commit adbb812

Browse files
committed
Use object values for build matrix
This allows us to avoid the bad switch reimplementation for the `build.runs-on` value.
1 parent 1232c69 commit adbb812

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

.github/workflows/container-image.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ jobs:
6262
fail-fast: false # NOTE(sg): allow matrix jobs to complete even if one of them fails
6363
matrix:
6464
platform:
65-
- linux/amd64
66-
- linux/arm64
65+
- name: linux/amd64
66+
runner: ubuntu-24.04
67+
- name: linux/arm64
68+
runner: ubuntu-24.04-arm
6769
permissions:
6870
# The permissions are set to allow the job to write to the GitHub Container Registry (GHCR) and read from the repository.
6971
attestations: write
@@ -80,11 +82,11 @@ jobs:
8082
repository-projects: read
8183
security-events: read
8284
statuses: read
83-
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-24.04' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }}
85+
runs-on: ${{ matrix.platform.runner }}
8486
steps:
8587
- name: Prepare environment for current platform
8688
run: |
87-
platform=${{ matrix.platform }}
89+
platform=${{ matrix.platform.name }}
8890
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
8991
- name: checkout
9092
uses: actions/checkout@v6
@@ -109,20 +111,20 @@ jobs:
109111
uses: docker/setup-buildx-action@v4
110112
with:
111113
endpoint: builders
112-
platforms: ${{ matrix.platform }}
114+
platforms: ${{ matrix.platform.name }}
113115
- name: Build and push by digest
114116
id: build
115117
uses: docker/build-push-action@v7
116118
env:
117119
DOCKER_BUILDKIT: 1
118120
with:
119121
context: .
120-
platforms: ${{ matrix.platform }}
122+
platforms: ${{ matrix.platform.name }}
121123
labels: ${{ steps.meta.outputs.labels }}
122124
annotations: ${{ steps.meta.outputs.annotations }}
123125
outputs: type=image,name=${{ env.GHCR_IMAGE }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
124-
cache-from: type=gha,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform }}
125-
cache-to: type=gha,mode=max,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform }}
126+
cache-from: type=gha,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform.name }}
127+
cache-to: type=gha,mode=max,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform.name }}
126128
build-args: |
127129
GITVERSION=${{ needs.get-version.outputs.gitversion }}
128130
PYVERSION=${{ needs.get-version.outputs.pyversion }}

0 commit comments

Comments
 (0)