Skip to content

Commit 59ed548

Browse files
committed
self-hosted-runners: make Actions Runner path customizable
Some Azure VM types have a temporary disk which is local to the VM and therefore provides _much_ faster disk IO than the OS Disk (or any other attached disk). Hosted GitHub Actions runners also leverage this disk and do their work in D:/a/_work, so let's use it too if we can. It leads to a ~25% speed increase when doing heavy IO operations. Ref: https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview#temporary-disk Ref: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources Signed-off-by: Dennis Ameling (he/him) <[email protected]>
1 parent 0878598 commit 59ed548

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

.github/workflows/create-azure-self-hosted-runners.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ jobs:
134134
| jq --raw-output .token)
135135
echo "::add-mask::$ACTIONS_RUNNER_TOKEN"
136136
echo ACTIONS_RUNNER_TOKEN=$ACTIONS_RUNNER_TOKEN >> $GITHUB_ENV
137+
138+
# The Azure VM type we use has blazing-fast local, temporary storage available as the D:\ drive.
139+
# The only downside is that, after dellocation, the contents of this disk (including the Actions Runner),
140+
# are destroyed. Let's only use it when we don't immediately deallocate the VM.
141+
if [[ "${{ env.DEALLOCATE_IMMEDIATELY }}" == "true" ]]; then
142+
echo "ACTIONS_RUNNER_PATH=C:\a" >> $GITHUB_ENV
143+
else
144+
echo "ACTIONS_RUNNER_PATH=D:\a" >> $GITHUB_ENV
145+
fi
137146
138147
- name: Azure Login
139148
uses: azure/login@v1
@@ -144,7 +153,7 @@ jobs:
144153
with:
145154
resourceGroupName: ${{ secrets.AZURE_RESOURCE_GROUP }}
146155
template: ./azure-self-hosted-runners/azure-arm-template.json
147-
parameters: ./azure-self-hosted-runners/azure-arm-template-example-parameters.json githubActionsRunnerRegistrationUrl="${{ env.ACTIONS_RUNNER_REGISTRATION_URL }}" githubActionsRunnerToken="${{ env.ACTIONS_RUNNER_TOKEN }}" postDeploymentPsScriptUrl="${{ env.POST_DEPLOYMENT_SCRIPT_URL }}" virtualMachineName=${{ steps.generate-vm-name.outputs.vm_name }} virtualMachineSize=${{ env.AZURE_VM_TYPE }} publicIpAddressName1=${{ steps.generate-vm-name.outputs.vm_name }}-ip adminUsername=${{ secrets.AZURE_VM_USERNAME }} adminPassword=${{ secrets.AZURE_VM_PASSWORD }} stopService={{ env.DEALLOCATE_IMMEDIATELY }}
156+
parameters: ./azure-self-hosted-runners/azure-arm-template-example-parameters.json githubActionsRunnerRegistrationUrl="${{ env.ACTIONS_RUNNER_REGISTRATION_URL }}" githubActionsRunnerToken="${{ env.ACTIONS_RUNNER_TOKEN }}" postDeploymentPsScriptUrl="${{ env.POST_DEPLOYMENT_SCRIPT_URL }}" virtualMachineName=${{ steps.generate-vm-name.outputs.vm_name }} virtualMachineSize=${{ env.AZURE_VM_TYPE }} publicIpAddressName1=${{ steps.generate-vm-name.outputs.vm_name }}-ip adminUsername=${{ secrets.AZURE_VM_USERNAME }} adminPassword=${{ secrets.AZURE_VM_PASSWORD }} stopService={{ env.DEALLOCATE_IMMEDIATELY }} githubActionsRunnerPath="${{ env.ACTIONS_RUNNER_PATH }}"
148157

149158
- name: Deallocate the VM for later use
150159
if: env.DEALLOCATE_IMMEDIATELY == 'true'

azure-self-hosted-runners/azure-arm-template.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"description": "GitHub Actions Runner registration token for the org/repo. Note that these tokens are only valid for one hour after creation!"
1717
}
1818
},
19+
"githubActionsRunnerPath": {
20+
"type": "string",
21+
"metadata": {
22+
"description": "Path to the Actions Runner. Keep this path short to prevent Long Path issues, e.g. D:\\a"
23+
}
24+
},
1925
"postDeploymentPsScriptUrl": {
2026
"type": "string",
2127
"minLength": 6,
@@ -256,7 +262,7 @@
256262
"value": "[parameters('location')]"
257263
},
258264
"arguments": {
259-
"value": "[concat('-GitHubActionsRunnerToken ', parameters('githubActionsRunnerToken'), ' -GithubActionsRunnerRegistrationUrl ', parameters('githubActionsRunnerRegistrationUrl'), ' -GithubActionsRunnerName ', parameters('virtualMachineName'), ' -StopService ', parameters('stopService'))]"
265+
"value": "[concat('-GitHubActionsRunnerToken ', parameters('githubActionsRunnerToken'), ' -GithubActionsRunnerRegistrationUrl ', parameters('githubActionsRunnerRegistrationUrl'), ' -GithubActionsRunnerName ', parameters('virtualMachineName'), ' -StopService ', parameters('stopService'), ' -GitHubActionsRunnerPath ', parameters('githubActionsRunnerPath'))]"
260266
}
261267
}
262268
},

azure-self-hosted-runners/post-deployment-script.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ param (
1616
# Stop Service immediately (useful for spinning up runners preemptively)
1717
[Parameter(Mandatory=$false)]
1818
[ValidateSet('true', 'false')]
19-
[string]$StopService = 'true'
19+
[string]$StopService = 'true',
20+
21+
# Path to the Actions Runner. Keep this path short to prevent Long Path issues, e.g. D:\a
22+
[Parameter(Mandatory=$true)]
23+
[string]$GitHubActionsRunnerPath
2024
)
2125

2226
Write-Output "Starting post-deployment script."
@@ -33,8 +37,6 @@ $GitHubActionsRunnerVersion = "2.300.2"
3337
$GithubActionsRunnerArch = "arm64"
3438
$GithubActionsRunnerHash = "9409e50d9ad33d8031355ed079b8f56cf3699f35cf5d0ca51e54deed432758ef"
3539
$GithubActionsRunnerLabels = "self-hosted,Windows,ARM64"
36-
# Keep this path short to prevent Long Path issues
37-
$GitHubActionsRunnerPath = "C:\a"
3840

3941
# ======================
4042
# WINDOWS DEVELOPER MODE

0 commit comments

Comments
 (0)