Skip to content

Commit 1d01ee3

Browse files
committed
BLO-4370 Allow multi-arch builds on matching runners
1 parent d174ed7 commit 1d01ee3

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

.github/workflows/template_gitops.yml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
docker-build-platforms:
2121
required: false
2222
type: string
23-
default: "linux/amd64,linux/arm64"
23+
default: "linux/amd64"
2424
docker-build-provenance:
2525
required: false
2626
type: string
@@ -72,6 +72,10 @@ on:
7272
required: false
7373
type: string
7474
default: "ubuntu-24.04"
75+
runs-on-arm:
76+
required: false
77+
type: string
78+
default: "ubuntu-24.04-arm"
7579
upwind-organization-id:
7680
required: false
7781
type: string
@@ -101,9 +105,47 @@ on:
101105
required: false
102106

103107
jobs:
108+
prepare-matrix:
109+
runs-on: ubuntu-latest
110+
outputs:
111+
matrix: ${{ steps.set-matrix.outputs.matrix }}
112+
steps:
113+
- name: Generate Matrix
114+
id: set-matrix
115+
shell: python
116+
run: |
117+
import os
118+
import json
119+
120+
platforms_input = "${{ inputs.docker-build-platforms }}"
121+
amd64_runner = "${{ inputs.runs-on }}"
122+
arm64_runner = "${{ inputs.runs-on-arm }}"
123+
124+
# split input "linux/amd64,linux/arm64" into list
125+
platforms = [p.strip() for p in platforms_input.split(',') if p.strip()]
126+
127+
include = []
128+
for p in platforms:
129+
runner = amd64_runner
130+
# Map linux/arm64 to a specific ARM runner
131+
# Adjust 'ubuntu-24.04-arm' to GitHub availability
132+
if "arm64" in p:
133+
runner = arm64_runner
134+
135+
include.append({"platform": p, "runner": runner})
136+
137+
matrix = {"include": include}
138+
139+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
140+
f.write(f"matrix={json.dumps(matrix)}")
141+
104142
gitops:
105-
name: GitOps
106-
runs-on: ${{ inputs.runs-on }}
143+
name: GitOps (${{ matrix.platform }})
144+
needs: prepare-matrix
145+
strategy:
146+
fail-fast: true
147+
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
148+
runs-on: ${{ matrix.runner }}
107149
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
108150

109151
env:
@@ -136,7 +178,7 @@ jobs:
136178
docker-build-secret-files: ${{ secrets.docker-build-secret-files }}
137179
docker-build-target: ${{ inputs.docker-build-target }}
138180
docker-build-outputs: ${{ inputs.docker-build-outputs }}
139-
docker-build-platforms: ${{ inputs.docker-build-platforms }}
181+
docker-build-platforms: ${{ matrix.platform }}
140182
docker-build-provenance: ${{ inputs.docker-build-provenance }}
141183
docker-disable-retagging: ${{ inputs.docker-disable-retagging }}
142184
docker-file: ${{ inputs.docker-file }}

0 commit comments

Comments
 (0)