Skip to content

Commit 8bf53d9

Browse files
🪲 [Fix]: Connect-GitHubAccount - Get Token (#122)
## Description - Fix an issue where the `Connect-GitHubAccount` would get object instead of value. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 1f9a870 commit 8bf53d9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/private/Commands/Initialize-RunnerEnvironment.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
Set-GitHubEnv -Name 'GITHUB_REPOSITORY_NAME' -Value $env:GITHUB_REPOSITORY_NAME
2020

2121
# Autologon if a token is present in environment variables
22-
$tokenVar = Get-ChildItem -Path 'Env:' | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1
22+
Write-Verbose (Get-ChildItem -Path 'Env:' | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Out-String)
23+
$tokenVar = Get-ChildItem -Path 'Env:' | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1 -ExpandProperty Value
2324
$tokenVarPresent = $tokenVar.count -gt 0 -and -not [string]::IsNullOrEmpty($tokenVar)
2425
if ($tokenVarPresent) {
2526
Connect-GitHubAccount -Repo $env:GITHUB_REPOSITORY_NAME -Owner $env:GITHUB_REPOSITORY_OWNER

src/public/Auth/Connect-GitHubAccount.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
$envVars = Get-ChildItem -Path 'Env:'
9999
Write-Debug 'Environment variables:'
100100
Write-Debug ($envVars | Format-Table -AutoSize | Out-String)
101-
$gitHubToken = $envVars | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1
101+
$gitHubToken = $envVars | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1 -ExpandProperty Value
102102
Write-Debug "GitHub token: [$gitHubToken]"
103103
$gitHubTokenPresent = $gitHubToken.count -gt 0 -and -not [string]::IsNullOrEmpty($gitHubToken)
104104
Write-Debug "GitHub token present: [$gitHubTokenPresent]"
@@ -202,9 +202,9 @@
202202
'sPAT' {
203203
Write-Verbose 'Logging in using GitHub access token...'
204204
Reset-GitHubConfig -Scope 'Auth'
205-
$prefix = $gitHubToken.Value -replace '_.*$', '_*'
205+
$prefix = $gitHubToken -replace '_.*$', '_*'
206206
$settings = @{
207-
AccessToken = ConvertTo-SecureString -AsPlainText $gitHubToken.Value
207+
AccessToken = ConvertTo-SecureString -AsPlainText $gitHubToken
208208
AccessTokenType = $prefix
209209
ApiBaseUri = 'https://api.github.com'
210210
ApiVersion = '2022-11-28'

0 commit comments

Comments
 (0)