Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
7 changes: 5 additions & 2 deletions src/functions/public/Auth/Connect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand All @@ -122,6 +124,7 @@
[switch] $Silent
)

$HostName = $HostName -replace '^https?://'
$ApiBaseUri = "https://api.$HostName"

$envVars = Get-ChildItem -Path 'Env:'
Expand Down