Skip to content

Commit

Permalink
🩹 [Patch]: Connect when on GitHub Actions (#120)
Browse files Browse the repository at this point in the history
## Description

- Connect when on GitHub Actions and pre-connect to current repo and
org/owner.

## Type of change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [x] 🩹 [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
  • Loading branch information
MariusStorhaug authored Aug 17, 2024
1 parent a62bac0 commit 9d9386c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/loader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions src/private/Commands/Initialize-RunnerEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 9d9386c

Please sign in to comment.