diff --git a/src/functions/private/Commands/Initialize-RunnerEnvironment.ps1 b/src/functions/private/Commands/Initialize-RunnerEnvironment.ps1 index 303d20ca9..d8c13cf71 100644 --- a/src/functions/private/Commands/Initialize-RunnerEnvironment.ps1 +++ b/src/functions/private/Commands/Initialize-RunnerEnvironment.ps1 @@ -23,7 +23,6 @@ $tokenVar = Get-ChildItem -Path 'Env:' | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1 -ExpandProperty Value $tokenVarPresent = $tokenVar.count -gt 0 -and -not [string]::IsNullOrEmpty($tokenVar) if ($tokenVarPresent) { - $HostName = $env:GITHUB_SERVER_URL -replace '^https?://' - Connect-GitHubAccount -Repo $env:GITHUB_REPOSITORY_NAME -Owner $env:GITHUB_REPOSITORY_OWNER -Host $HostName + Connect-GitHubAccount -Repo $env:GITHUB_REPOSITORY_NAME -Owner $env:GITHUB_REPOSITORY_OWNER -Server $env:GITHUB_SERVER_URL } } diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index a1c88acfc..58f885f37 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -109,10 +109,12 @@ [Parameter()] [string] $ApiVersion = '2022-11-28', - # The host to connect to. + # The host to connect to. Can use $env:GITHUB_SERVER_URL to set the host, as the protocol is removed automatically. + # Example: github.com, github.enterprise.com, msx.ghe.com [Parameter()] [Alias('Host')] - [uri] $HostName = 'github.com', + [Alias('Server')] + [string] $HostName = 'github.com', # Suppresses the output of the function. [Parameter()] @@ -122,6 +124,7 @@ [switch] $Silent ) + $HostName = $HostName -replace '^https?://' $ApiBaseUri = "https://api.$HostName" $envVars = Get-ChildItem -Path 'Env:'