|
22 | 22 | "description": "Path to the Actions Runner. Keep this path short to prevent Long Path issues, e.g. D:\\a"
|
23 | 23 | }
|
24 | 24 | },
|
25 |
| - "postDeploymentPsScriptUrl": { |
| 25 | + "postDeploymentScriptZipBase64": { |
26 | 26 | "type": "string",
|
27 | 27 | "minLength": 6,
|
28 | 28 | "metadata": {
|
29 |
| - "description": "URL to the post-deployment PowerShell script. E.g. https://raw.githubusercontent.com/git-for-windows/git-for-windows-automation/main/azure-self-hosted-runners/post-deployment-script.ps1" |
| 29 | + "description": "Base64-encoded .zip file containing the post-deployment script" |
| 30 | + } |
| 31 | + }, |
| 32 | + "postDeploymentScriptFileName": { |
| 33 | + "type": "string", |
| 34 | + "minLength": 6, |
| 35 | + "metadata": { |
| 36 | + "description": "File name of the post-deployment script" |
30 | 37 | }
|
31 | 38 | },
|
32 | 39 | "computerName": {
|
|
118 | 125 | "vnetName": "[concat(parameters('virtualMachineName'), '-vnet')]",
|
119 | 126 | "vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', concat(parameters('virtualMachineName'), '-vnet'))]",
|
120 | 127 | "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
|
121 |
| - "UriFileNamePieces": "[split(parameters('postDeploymentPsScriptUrl'), '/')]", |
122 |
| - "firstFileNameString": "[variables('UriFileNamePieces')[sub(length(variables('UriFileNamePieces')), 1)]]", |
123 |
| - "firstFileNameBreakString": "[split(variables('firstFileNameString'), '?')]", |
124 |
| - "firstFileName": "[variables('firstFileNameBreakString')[0]]", |
125 | 128 | "postDeploymentScriptArguments": "[concat('-GitHubActionsRunnerToken ', parameters('githubActionsRunnerToken'), ' -GithubActionsRunnerRegistrationUrl ', parameters('githubActionsRunnerRegistrationUrl'), ' -GithubActionsRunnerName ', parameters('virtualMachineName'), ' -Ephemeral ', parameters('ephemeral'), ' -StopService ', parameters('stopService'), ' -GitHubActionsRunnerPath ', parameters('githubActionsRunnerPath'))]"
|
126 | 129 | },
|
127 | 130 | "resources": [
|
|
269 | 272 | "type": "CustomScriptExtension",
|
270 | 273 | "typeHandlerVersion": "1.9",
|
271 | 274 | "autoUpgradeMinorVersion": true,
|
272 |
| - "settings": { |
273 |
| - "fileUris": "[split(parameters('postDeploymentPsScriptUrl'), ' ')]" |
274 |
| - }, |
275 | 275 | "protectedSettings": {
|
276 |
| - "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', variables('firstFileName'), ' ', variables('postDeploymentScriptArguments'))]" |
| 276 | + "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -Command \"[System.IO.File]::WriteAllBytes(\\\"tmp.zip\\\", [System.Convert]::FromBase64String(\\\"', parameters('postDeploymentScriptZipBase64'), '\\\")); Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory(\\\"tmp.zip\\\", \\\".\\\"); & .\\', parameters('postDeploymentScriptFileName'), ' ', variables('postDeploymentScriptArguments'), '\"')]" |
277 | 277 | }
|
278 | 278 | }
|
279 | 279 | }
|
|
0 commit comments