Last active
July 8, 2024 13:30
-
-
Save jonico/a94d03cac7a858e0613926d9f1bc7f2b to your computer and use it in GitHub Desktop.
Dynamic selection of GitHub Runners - as GitHub Action matrix builds currently do not allow dynamic values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
runner: ${{ steps.runner.outputs.runner }} | |
steps: | |
- id: runner | |
run: echo "::set-output name=runner::macos-latest" | |
test: | |
needs: [build] | |
runs-on: ${{ needs.build.outputs.runner }} | |
steps: | |
- run: echo I Ran |
@truonghuynguyen: you could experiment with outputs in list format similar to https://github.com/jonico/visualize-actions-matrix-builds-on-k8s/blob/master/.github/workflows/visualize-matrix-build-led.yml#L58
@truonghuynguyen, I have exactly same needs, and it works for me:
runs-on: [ self-hosted, "${{ needs.build.outputs.runner }}" ]
Unfortunately, I couldn't find how to attach several runners dynamically.
I didn't test but, If you have fixed number of runners, than you might try like this:
runs-on: [ self-hosted, "${{ needs.build.outputs.runner1 }}", "${{ needs.build.outputs.runner2 }}" ]
This was super helpful for a project I'm working on, thanks! 🎉
@truonghuynguyen, I have exactly same needs, and it works for me:
runs-on: [ self-hosted, "${{ needs.build.outputs.runner }}" ]
Unfortunately, I couldn't find how to attach several runners dynamically. I didn't test but, If you have fixed number of runners, than you might try like this:
runs-on: [ self-hosted, "${{ needs.build.outputs.runner1 }}", "${{ needs.build.outputs.runner2 }}" ]
Works fine for me, thanks!! 🎉🎉
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @jonico, can we do multiple tags? I tried the similar as above, the value of
outouts.runner
is[ tag1, tag2 ]
, but it treatsoutouts.runner
as a whole string, instead of an array of tags.