Skip to content

Commit 8b263c8

Browse files
Lower PowerShell version requirement to 3.0
Changed the script to require PowerShell 3.0 instead of 5.1 and updated the Key Vault secret retrieval to be compatible with PowerShell 3.0 by extracting the secret value using SecretValueText.
1 parent 59b255d commit 8b263c8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

gh-runners/init.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Requires -Version 5.1
1+
#Requires -Version 3.0
22
<#
33
.SYNOPSIS
44
GitHub Actions runner configuration script for Azure VMSS
@@ -61,14 +61,16 @@ try {
6161
Write-Log " - VM Name: $($env:COMPUTERNAME)"
6262

6363
Write-Log "Retrieving GitHub PAT from Key Vault..."
64-
$GithubToken = Get-AzKeyVaultSecret `
64+
$secretObj = Get-AzKeyVaultSecret `
6565
-VaultName $KeyVaultName `
66-
-Name "GITHUB-RUNNER-TOKEN" `
67-
-AsPlainText
66+
-Name "GITHUB-RUNNER-TOKEN"
6867

69-
if (-not $GithubToken) {
68+
if (-not $secretObj) {
7069
throw "Failed to retrieve GitHub token from Key Vault"
7170
}
71+
72+
# PS 3.0 compatible way to get plaintext secret
73+
$GithubToken = $secretObj.SecretValueText
7274
Write-Log "GitHub PAT retrieved successfully"
7375

7476
Write-Log "Requesting runner registration token from GitHub API..."

0 commit comments

Comments
 (0)