|
5 | 5 | inputs: |
6 | 6 | # THE FOLLOWING INPUTS ARE UNIQUE TO THIS WORKFLOW |
7 | 7 | # MULTIARCH CONFIGS |
8 | | - server-size: |
9 | | - description: "Size of the Grafana self-hosted runner" |
| 8 | + runner-type: |
| 9 | + description: | |
| 10 | + Setting this flag will dictate the default instance types to use. |
| 11 | + Allowed values are 'self-hosted' or 'github'. |
| 12 | + required: false |
| 13 | + default: "self-hosted" |
| 14 | + type: string |
| 15 | + runner-type-arm64: |
| 16 | + description: | |
| 17 | + The instance type to use for arm64 builds. |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + runner-type-manifest: |
| 21 | + description: | |
| 22 | + The instance type to use when building and pushing the manifest. |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + runner-type-x64: |
| 26 | + description: | |
| 27 | + The instance type to use for x64 builds. |
10 | 28 | required: false |
11 | | - default: "small" |
12 | 29 | type: string |
13 | 30 |
|
14 | 31 | # The following inputs are identical to the inputs |
@@ -190,18 +207,21 @@ on: |
190 | 207 | version: |
191 | 208 | description: "Generated Docker image version (from docker/metadata-action)" |
192 | 209 | value: ${{ jobs.build-and-push.outputs.version }} |
193 | | - runner_arches: |
| 210 | + runner-arches: |
194 | 211 | description: "The list of OS used to build images (for mapping to self hosted runners)" |
195 | | - value: ${{ jobs.prepare-matrix.outputs.runner_arches }} |
| 212 | + value: ${{ jobs.prepare-matrix.outputs.runner-arches }} |
196 | 213 |
|
197 | 214 | env: |
198 | 215 | ARCH_TO_PLATFORM_MAP: '{"arm64": "linux/arm64", "x64": "linux/amd64"}' |
199 | 216 |
|
200 | 217 | jobs: |
201 | 218 | prepare-matrix: |
202 | | - runs-on: ubuntu-arm64-small |
| 219 | + runs-on: ${{ inputs.runner-type == 'self-hosted' && 'ubuntu-x64-small' || 'ubuntu-latest' }} |
203 | 220 | outputs: |
204 | | - runner_arches: ${{ steps.matrix.outputs.runner_arches }} |
| 221 | + runner-arches: ${{ steps.matrix.outputs.runner-arches }} |
| 222 | + runner-type-x64: ${{ steps.runners.outputs.runner-type-x64 }} |
| 223 | + runner-type-arm64: ${{ steps.runners.outputs.runner-type-arm64 }} |
| 224 | + runner-type-manifest: ${{ steps.runners.outputs.runner-type-manifest }} |
205 | 225 | steps: |
206 | 226 | - id: matrix |
207 | 227 | shell: bash |
@@ -232,15 +252,54 @@ jobs: |
232 | 252 | MATRIX=$(echo "$PS" | jq -R -c 'split(",")') |
233 | 253 |
|
234 | 254 | # Export as GitHub Action output |
235 | | - echo "runner_arches=$MATRIX" | tee -a "${GITHUB_OUTPUT}" |
| 255 | + echo "runner-arches=$MATRIX" | tee -a "${GITHUB_OUTPUT}" |
| 256 | + - id: runners |
| 257 | + shell: bash |
| 258 | + env: |
| 259 | + RUNNER_TYPE: ${{ inputs.runner-type }} |
| 260 | + X64_TYPE: ${{ inputs.runner-type-x64 }} |
| 261 | + ARM64_TYPE: ${{ inputs.runner-type-arm64 }} |
| 262 | + MANIFEST_TYPE: ${{ inputs.runner-type-manifest }} |
| 263 | + run: | |
| 264 | + ############################################################# |
| 265 | + # This step sets up the runner types for the remaining jobs |
| 266 | + ############################################################# |
| 267 | +
|
| 268 | + # Set default runner types based on RUNNER_TYPE |
| 269 | + case "$RUNNER_TYPE" in |
| 270 | + self-hosted) |
| 271 | + DEFAULT_X64="ubuntu-x64-small" |
| 272 | + DEFAULT_ARM64="ubuntu-arm64-small" |
| 273 | + DEFAULT_MANIFEST="ubuntu-arm64-small" |
| 274 | + ;; |
| 275 | + github) |
| 276 | + DEFAULT_X64="ubuntu-24.04" |
| 277 | + DEFAULT_ARM64="ubuntu-24.04-arm" |
| 278 | + DEFAULT_MANIFEST="ubuntu-24.04-arm" |
| 279 | + ;; |
| 280 | + *) |
| 281 | + echo "Unknown RUNNER_TYPE: $RUNNER_TYPE" >&2 |
| 282 | + exit 1 |
| 283 | + ;; |
| 284 | + esac |
| 285 | +
|
| 286 | + # Use user-provided overrides if they exist, otherwise use defaults |
| 287 | + X64_OUT="${X64_TYPE:-$DEFAULT_X64}" |
| 288 | + ARM64_OUT="${ARM64_TYPE:-$DEFAULT_ARM64}" |
| 289 | + MANIFEST_OUT="${MANIFEST_TYPE:-$DEFAULT_MANIFEST}" |
| 290 | +
|
| 291 | + # Export to GitHub Actions outputs |
| 292 | + echo "runner-type-x64=$X64_OUT" | tee -a "${GITHUB_OUTPUT}" |
| 293 | + echo "runner-type-arm64=$ARM64_OUT" | tee -a "${GITHUB_OUTPUT}" |
| 294 | + echo "runner-type-manifest=$MANIFEST_OUT" | tee -a "${GITHUB_OUTPUT}" |
236 | 295 |
|
237 | 296 | build-and-push: |
238 | 297 | needs: prepare-matrix |
239 | 298 | strategy: |
240 | 299 | fail-fast: false |
241 | 300 | matrix: |
242 | | - arch: ${{ fromJson(needs.prepare-matrix.outputs.runner_arches) }} |
243 | | - runs-on: ubuntu-${{ matrix.arch }}-${{ inputs.server-size }} |
| 301 | + arch: ${{ fromJson(needs.prepare-matrix.outputs.runner-arches) }} |
| 302 | + runs-on: ${{ matrix.arch == 'x64' && needs.prepare-matrix.outputs.runner-type-x64 || needs.prepare-matrix.outputs.runner-type-arm64 }} |
244 | 303 | outputs: |
245 | 304 | annotations: ${{ steps.build.outputs.annotations }} |
246 | 305 | digest: ${{ steps.build.outputs.digest }} |
@@ -312,8 +371,8 @@ jobs: |
312 | 371 | platform: ${{ env.PLATFORM }} |
313 | 372 |
|
314 | 373 | merge-digest: |
315 | | - runs-on: ubuntu-arm64-small |
316 | | - needs: build-and-push |
| 374 | + runs-on: ${{ needs.prepare-matrix.outputs.runner-type-manifest }} |
| 375 | + needs: [prepare-matrix, build-and-push] |
317 | 376 | permissions: |
318 | 377 | contents: read |
319 | 378 | id-token: write |
|
0 commit comments