Skip to content

Commit 2c7f823

Browse files
committed
Automatically delete self-hosted runner VMs when no longer needed
We're using ephemeral runners. This means that after completing a job, the runner is no longer used and can be decommissioned. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 912a174 commit 2c7f823

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

GitForWindowsHelper/self-hosted-arm64-runners.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,24 @@ module.exports = async (context, req) => {
5353
return `The workflow run to create the self-hosted runner VM was started at ${answer.html_url}`
5454
}
5555

56+
if (action === 'completed') {
57+
// Delete the runner
58+
const triggerWorkflowDispatch = require('./trigger-workflow-dispatch')
59+
const token = await getToken()
60+
const vmName = req.body.workflow_job.runner_name
61+
const answer = await triggerWorkflowDispatch(
62+
context,
63+
token,
64+
'git-for-windows',
65+
'git-for-windows-automation',
66+
'delete-self-hosted-runner.yml',
67+
'main', {
68+
runner_name: vmName
69+
}
70+
)
71+
72+
return `The workflow run to delete the self-hosted runner VM '${vmName}' was started at ${answer.html_url}`
73+
}
74+
5675
return `Unhandled action: ${action}`
5776
}

0 commit comments

Comments
 (0)