Skip to content

Commit 7e8d786

Browse files
committed
ci: try to fix runner selection
1 parent 9826dc7 commit 7e8d786

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

.github/workflows/wc-build-push.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ on:
3131
default: '{"runner": ["ubuntu-latest", "ubuntu-24.04-arm"]}'
3232
default-runner-labels:
3333
description: >-
34-
String or JSON array of runner labels for non-build jobs.
35-
Example: ["self-hosted", "linux", "x86_64"] or ubuntu-latest.
34+
Single runner label OR JSON array of runner labels for non-build jobs.
35+
Examples:
36+
ubuntu-latest
37+
["ubuntu-latest"]
38+
["self-hosted", "linux", "x86_64"]
39+
Provide a valid JSON array (starting with '[') to use multiple labels; any other value is treated as a single label string.
3640
required: false
3741
type: string
3842
default: ubuntu-latest
@@ -123,7 +127,9 @@ jobs:
123127
retention-days: 1
124128

125129
merge-image:
126-
runs-on: ${{ fromJson(inputs.default-runner-labels) }}
130+
# Support either a plain single label (e.g. ubuntu-latest) OR a JSON array of labels.
131+
# If the input starts & ends with brackets we attempt JSON parsing; otherwise we pass the raw string.
132+
runs-on: ${{ (startsWith(inputs.default-runner-labels, '[') && endsWith(inputs.default-runner-labels, ']')) && fromJson(inputs.default-runner-labels) || inputs.default-runner-labels }}
127133
needs:
128134
- build-push
129135
- sanitize-image-name

.github/workflows/wc-sanitize-image-name.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ on:
1313
required: true
1414
type: string
1515
runner-labels:
16-
description: "Runner to use for the job, will be passed to `runs-on`"
16+
description: >-
17+
Runner selection for this job. Accepts either a single label (e.g. ubuntu-latest)
18+
or a JSON array of labels (e.g. ["self-hosted", "linux", "x86_64"]).
19+
If the value begins with '[' it will be parsed as JSON.
1720
required: true
1821
type: string
1922
outputs:
@@ -31,7 +34,8 @@ permissions: {}
3134

3235
jobs:
3336
sanitize-inputs:
34-
runs-on: ${{ fromJson(inputs.runner-labels) }}
37+
# Allow either raw single label or JSON array of labels
38+
runs-on: ${{ (startsWith(inputs.runner-labels, '[') && endsWith(inputs.runner-labels, ']')) && fromJson(inputs.runner-labels) || inputs.runner-labels }}
3539
outputs:
3640
image-basename: ${{ steps.sanitize-image-name.outputs.sanitized-basename }}
3741
image-name: ${{ steps.sanitize-image-name.outputs.sanitized-image-name }}

0 commit comments

Comments
 (0)