Skip to content

Commit c8c1abf

Browse files
committed
ci(gh-actions): Allow workflow callers to specify the runner as workflow input
1 parent d9185d5 commit c8c1abf

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
# Allow this workflow to be reused by other workflows:
55
workflow_call:
66
inputs:
7+
runner:
8+
description: 'JSON-encoded list of runner labels'
9+
default: '["self-hosted"]'
10+
required: false
11+
type: string
712
do_deploy:
813
description: 'Deploy to cachix'
914
type: 'boolean'
@@ -45,7 +50,7 @@ concurrency:
4550

4651
jobs:
4752
post-initial-comment:
48-
runs-on: self-hosted
53+
runs-on: ${{ fromJSON(inputs.runner) }}
4954
steps:
5055
- name: 'Post initial package status comment'
5156
uses: marocchino/[email protected]
@@ -58,7 +63,7 @@ jobs:
5863
5964
generate-matrix-matrix:
6065
name: Generate Matrix of Matrices
61-
runs-on: self-hosted
66+
runs-on: ${{ fromJSON(inputs.runner) }}
6267
steps:
6368
- name: Install Nix
6469
uses: metacraft-labs/nixos-modules/.github/install-nix@main
@@ -83,7 +88,7 @@ jobs:
8388

8489
generate-matrix:
8590
needs: generate-matrix-matrix
86-
runs-on: self-hosted
91+
runs-on: ${{ fromJSON(inputs.runner) }}
8792
strategy:
8893
matrix: ${{fromJSON(needs.generate-matrix-matrix.outputs.gen_matrix)}}
8994
name: Generate Matrix ${{ matrix.digit != -1 && matrix.digit || '' }}
@@ -119,7 +124,7 @@ jobs:
119124
matrix: ${{ steps.generate-matrix.outputs.matrix }}
120125

121126
slurp-matrix:
122-
runs-on: self-hosted
127+
runs-on: ${{ fromJSON(inputs.runner) }}
123128
needs: generate-matrix
124129
name: Merge matrices
125130
outputs:
@@ -207,7 +212,7 @@ jobs:
207212
cachix push ${{ vars.CACHIX_CACHE }} ${{ matrix.output }}
208213
209214
results:
210-
runs-on: self-hosted
215+
runs-on: ${{ fromJSON(inputs.runner) }}
211216
name: Final Results
212217
needs: [build, slurp-matrix]
213218
if: always()

.github/workflows/update-flake-lock.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name: "Update Nix Flake lockfile"
33
on:
44
# Allow this workflow to be reused by other workflows:
55
workflow_call:
6+
inputs:
7+
runner:
8+
description: 'JSON-encoded list of runner labels'
9+
default: '["self-hosted"]'
10+
required: true
11+
type: string
12+
613
secrets:
714
NIX_GITHUB_TOKEN:
815
description: GitHub token to add as access-token in nix.conf
@@ -26,7 +33,7 @@ on:
2633

2734
jobs:
2835
main:
29-
runs-on: self-hosted
36+
runs-on: ${{ fromJSON(inputs.runner) }}
3037

3138
steps:
3239
- uses: actions/checkout@v4

.github/workflows/update-flake-packages.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name: "Update Flake Packages ❄️"
33
on:
44
# Allow this workflow to be reused by other workflows:
55
workflow_call:
6+
inputs:
7+
runner:
8+
description: 'JSON-encoded list of runner labels'
9+
default: '["self-hosted"]'
10+
required: true
11+
type: string
12+
613
secrets:
714
NIX_GITHUB_TOKEN:
815
description: GitHub token to add as access-token in nix.conf
@@ -26,7 +33,7 @@ on:
2633

2734
jobs:
2835
updateFlakePackages:
29-
runs-on: self-hosted
36+
runs-on: ${{ fromJSON(inputs.runner) }}
3037
steps:
3138
- name: Checkout repository
3239
uses: actions/checkout@v4

0 commit comments

Comments
 (0)