diff --git a/src/loader.ps1 b/src/loader.ps1 index 4525cc8e..a3e33597 100644 --- a/src/loader.ps1 +++ b/src/loader.ps1 @@ -7,10 +7,3 @@ Initialize-Store -Name 'GitHubPowerShell' -SecretVaultName $script:Config.Name - if ($env:GITHUB_ACTIONS -eq 'true') { Initialize-RunnerEnvironment } - -# Autologon if a token is present in environment variables -$envVar = Get-ChildItem -Path 'Env:' | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1 -$envVarPresent = $envVar.count -gt 0 -if ($envVarPresent) { - Connect-GitHubAccount -} diff --git a/src/private/Commands/Initialize-RunnerEnvironment.ps1 b/src/private/Commands/Initialize-RunnerEnvironment.ps1 index 5fe36517..331936d8 100644 --- a/src/private/Commands/Initialize-RunnerEnvironment.ps1 +++ b/src/private/Commands/Initialize-RunnerEnvironment.ps1 @@ -18,4 +18,10 @@ $env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/' Set-GitHubEnv -Name 'GITHUB_REPOSITORY_NAME' -Value $env:GITHUB_REPOSITORY_NAME + # Autologon if a token is present in environment variables + $envVar = Get-ChildItem -Path 'Env:' | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1 + $envVarPresent = $envVar.count -gt 0 + if ($envVarPresent) { + Connect-GitHubAccount -Repo $env:GITHUB_REPOSITORY_NAME -Owner $env:GITHUB_REPOSITORY_OWNER + } }