Skip to content

Commit 912a174

Browse files
committed
Automatically spin up a self-hosted ARM64 runner as needed
When we receive an event indicating that a workflow job was queued that requires a Windows/ARM64 runner, let's let our automation do its magic and create a new such runner. It does take a bit of patience to do it this way: whenever a new workflow job is queued, it takes about 7-8 minutes to create the new runner. An alternative would be to pre-allocate runner VMs, and immediately deallocate them to await being started when needed. But even that start-up time takes a couple of minutes and would not be immediate. Besides, it would cost quite a lot more Azure credits: merely keeping around a fast disk has a non-negligible cost. Yet another alternative would be to pre-allocate runner VMs and keep them running. However, that way we would quite handily run through all of the monthly-available Azure credits in no time. So let's just go with the 7-8 minutes solution, it's not like we're intending to run many more than a dozen Windows/ARM64 builds per month. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 0c27905 commit 912a174

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

GitForWindowsHelper/self-hosted-arm64-runners.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,23 @@ module.exports = async (context, req) => {
3535
throw new Error(`${sender} is not allowed to do that`)
3636
}
3737

38+
if (action === 'queued') {
39+
// Spin up a new runner
40+
const triggerWorkflowDispatch = require('./trigger-workflow-dispatch')
41+
const token = await getToken()
42+
const answer = await triggerWorkflowDispatch(
43+
context,
44+
token,
45+
'git-for-windows',
46+
'git-for-windows-automation',
47+
'create-azure-self-hosted-runners.yml',
48+
'main', {
49+
runner_scope: 'repo-level'
50+
}
51+
)
52+
53+
return `The workflow run to create the self-hosted runner VM was started at ${answer.html_url}`
54+
}
55+
3856
return `Unhandled action: ${action}`
3957
}

0 commit comments

Comments
 (0)