Feature Request: Automatically switch to Github runner if self hosted runner is not available #20019
Replies: 18 comments 11 replies
-
I was looking for something like this as well.. Something like: And GH does not need to differentiate between Self Hosted or GH Runmers... Use the priority in the list above to whatever labeled Runner is available |
Beta Was this translation helpful? Give feedback.
-
@CoreCypator Hey can you please tell us how to give priority in the list above? In this example, a self-hosted runner that matches all three labels will be eligible to run the job: |
Beta Was this translation helpful? Give feedback.
-
There could be a fallback-runs-on parameter that looks the same as the runs-on property, but runs-on will be tried first and if no runners are online then the fallback-runs-on runners would be tried. Then the 60 minute timeout could kick in after that? This would be quite a cool feature that I could see being used as a way to spin up local runners for offsetting build costs etc. |
Beta Was this translation helpful? Give feedback.
-
I second this! In my case, I want this feature because my self-hosted runner may be offline (for maintenance or whatever reasons), and it would be really nice if these queued CI jobs could automatically switch to GitHub runners after some time. |
Beta Was this translation helpful? Give feedback.
-
Hey guys ... so.. has this been picked up yet or considered? |
Beta Was this translation helpful? Give feedback.
-
Did you ever try to assign your self-hosted runner to GitHub hosted runner labels like I observerd these priorities if you use
See https://docs.github.com/en/actions/hosting-your-own-runners/using-labels-with-self-hosted-runners for how to label self-hosted runners. There are no fancy timeout or other mechanism, GitHub Hosted Runners are also used if you have more parallel jobs than self-hosted runners EDIT on: push
jobs:
_:
runs-on: ubuntu-latest # This might run on your self-hosted runner if it is online and idle
steps:
- run: uname -a |
Beta Was this translation helpful? Give feedback.
-
For us, the important point of such a feature would be that it wouldn't switch to a Github runner if the self-hosted runners are merely busy. Only if they are not online at all. |
Beta Was this translation helpful? Give feedback.
-
While I'd love to have this, there is something that repository owners can do while they wait for something better: I'm slowly offering variations of this pattern to public repositories as I trip on workflows that require self-hosted runners. |
Beta Was this translation helpful? Give feedback.
-
I've had some success using this pattern...
Replace This will run Ideally, I'd like a way to detect that my runner is online, but I couldn't figure out how to do that. Is there a way to get a list of online runners? |
Beta Was this translation helpful? Give feedback.
-
Hello ! Any news on this ? :) Like @CoreCypator said, this would be perfect |
Beta Was this translation helpful? Give feedback.
-
Hi! |
Beta Was this translation helpful? Give feedback.
-
The enhancement proposes the addition of automatic support in GitHub Actions to utilize a GitHub runner if a self-hosted runner is unavailable. Specifically, it suggests setting up a scenario where a single self-hosted runner is configured. If this runner is accessible, the pipeline will utilize it; however, if the self-hosted runner is not available, the pipeline will seamlessly switch to using a GitHub runner to complete its tasks. This approach ensures smooth workflow execution even in cases where the preferred self-hosted runner is not accessible. |
Beta Was this translation helpful? Give feedback.
-
Answer from a github staff member would be nice! |
Beta Was this translation helpful? Give feedback.
-
Any news on this? |
Beta Was this translation helpful? Give feedback.
-
Dynamically Selecting GitHub Action Runners Based on Availability 🚀 Hello everyone, I wanted to share a solution for dynamically selecting GitHub Action runners based on their availability and status. This can be particularly useful if you have self-hosted runners and want to fall back to GitHub-hosted runners when none of your self-hosted runners are available. Here’s a simplified example of how you can achieve this: jobs:
check-runner:
runs-on: ubuntu-latest
outputs:
runner-label: ${{ steps.set-runner.outputs.runner-label }}
steps:
- name: Set runner
id: set-runner
run: |
runners=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners")
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
if [ -n "$available" ]; then
echo "runner-label=self-hosted" >> $GITHUB_OUTPUT
else
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
fi
build:
needs: check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build code
run: echo "Building on runner ${{ needs.check-runner.outputs.runner-label }}" Key Points:
Stay productive and healthy, everyone! Ensure your codes are as clean as your hands, and may your builds be as robust as your immune system. Happy coding! Best regards, |
Beta Was this translation helpful? Give feedback.
-
What about the other way arround? Switching to a self-hosted runner if the spending limit has been reached? Would this work the same way? |
Beta Was this translation helpful? Give feedback.
-
This is relevant also for me. What about if runner selection could be even more generic, something like; runs-on:
- labels: [self-hosted, linux-fast-machine] # try to pick this runner first
timeout-minutes: 0 # timeout for such runner
- labels: [self-hosted, linux-low-machine] # if not available, pick this runner then
timeout-minutes: 0
- labels: [ubuntu-latest] # if above not available, pick this runner last
timeout-minutes: 10 In above example we would have 3 different kind of runners, 2x self-hosted ones, one more powerful and one slower, and for backup plan we can use GitHub hosted runners. More powerful would be most efficient from job point of view, but if it's busy we can still go forward with slower options. This would allow to kind of priorities runners more generic way and configure how long time job can wait runner for each group. Propose here could be option when number of affected jobs and runners are rather small, but when workflows spread to several teams and hundreds of files, it might be too hard to maintain. |
Beta Was this translation helpful? Give feedback.
-
Hey there from Actions 👋 To provide an update here, we do not have this on our prioritized list for this year. It seems like there are some workarounds proposed here in the thread that work. Just to set expectations, we do not currently have plans to support this as a first party feature. |
Beta Was this translation helpful? Give feedback.
-
Describe the enhancement
Add support in Github action which will pick Github runner if self hosted runner is not available automatically.
e.g. Setup single self hosted runner. If it is available then pipeline should run using self hosted runner and if it is not then pipeline should use Github Runner and complete its job.
Beta Was this translation helpful? Give feedback.
All reactions