Skip to content

Commit 7798914

Browse files
🚀 [Feature]: Added functionality to pass AccessToken for Connect-GitHub (#142)
## Description - Added functionality to pass `AccessToken` for `Connect-GitHub`. - Makes it possible to pass IATs via parameter. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [x] 🚀 [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 84dee2c commit 7798914

File tree

5 files changed

+203
-194
lines changed

5 files changed

+203
-194
lines changed

src/functions/private/Commands/Initialize-RunnerEnvironment.ps1

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/'
1919
Set-GitHubEnv -Name 'GITHUB_REPOSITORY_NAME' -Value $env:GITHUB_REPOSITORY_NAME
2020

21-
# Autologon if a token is present in environment variables
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
24-
$tokenVarPresent = $tokenVar.count -gt 0 -and -not [string]::IsNullOrEmpty($tokenVar)
25-
if ($tokenVarPresent) {
26-
Connect-GitHubAccount -Repo $env:GITHUB_REPOSITORY_NAME -Owner $env:GITHUB_REPOSITORY_OWNER -Server $env:GITHUB_SERVER_URL
21+
$params = @{
22+
Owner = $env:GITHUB_REPOSITORY_OWNER
23+
Repo = $env:GITHUB_REPOSITORY_NAME
24+
Server = $env:GITHUB_SERVER_URL
2725
}
26+
Connect-GitHubAccount @params
2827
}

0 commit comments

Comments
 (0)