Skip to content

Commit fe43ffe

Browse files
🩹 [Patch]: Update environment variable prefixes for GitHub script inputs (#43)
## Description This pull request focuses on updating environment variable names across multiple scripts to ensure consistency and clarity. The changes involve renaming variables from `GITHUB_ACTION_INPUT_*` to `PSMODULE_GITHUB_SCRIPT_INPUT_*`. This is to reduce the change of clobbering the envvars for the GitHub-Script action. Aligns with a undocumented decision of having all inputs of actions and workflows as `<OWNER>_<REPO_NAME>_INPUT_*`. - Fixes #36 As this is internals of the action, this is deemed a patch update as nothing should rely on these variables apart from the scripts in the action. * Updated environment variable names in `action.yml` to use the `PSMODULE_GITHUB_SCRIPT_INPUT_*` prefix. * Modified `scripts/info.ps1` to reflect the new environment variable names for `ShowInfo`, `Token`, and `Debug` settings. [[1]](diffhunk://#diff-82c586f67d16e32953b47a962c269d0a484f8aa660d71ad354e91fd2d4334cd9L15-R16) [[2]](diffhunk://#diff-82c586f67d16e32953b47a962c269d0a484f8aa660d71ad354e91fd2d4334cd9L31-R35) [[3]](diffhunk://#diff-82c586f67d16e32953b47a962c269d0a484f8aa660d71ad354e91fd2d4334cd9L63-R64) * Adjusted `scripts/init.ps1` to use the updated environment variable names for `ShowInit`, `Version`, `Prerelease`, `Token`, `ClientID`, and `PrivateKey`. [[1]](diffhunk://#diff-f47ceebe9ade2bb55cede031de8267e9c87b09336a93fcd557c02c1f488554b6L13-R24) [[2]](diffhunk://#diff-f47ceebe9ade2bb55cede031de8267e9c87b09336a93fcd557c02c1f488554b6L76-R78) [[3]](diffhunk://#diff-f47ceebe9ade2bb55cede031de8267e9c87b09336a93fcd557c02c1f488554b6L96-R98) * Changed `scripts/outputs.ps1` to use the new environment variable name for `ShowOutput`. ## 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
1 parent 530913e commit fe43ffe

File tree

4 files changed

+37
-28
lines changed

4 files changed

+37
-28
lines changed

action.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ runs:
6464
id: RunGitHubScript
6565
working-directory: ${{ inputs.WorkingDirectory }}
6666
env:
67-
GITHUB_ACTION_INPUT_Token: ${{ inputs.Token }}
68-
GITHUB_ACTION_INPUT_ClientID: ${{ inputs.ClientID }}
69-
GITHUB_ACTION_INPUT_PrivateKey: ${{ inputs.PrivateKey }}
70-
GITHUB_ACTION_INPUT_Debug: ${{ inputs.Debug }}
71-
GITHUB_ACTION_INPUT_Verbose: ${{ inputs.Verbose }}
72-
GITHUB_ACTION_INPUT_Version: ${{ inputs.Version }}
73-
GITHUB_ACTION_INPUT_ShowInit: ${{ inputs.ShowInit }}
74-
GITHUB_ACTION_INPUT_ShowInfo: ${{ inputs.ShowInfo }}
75-
GITHUB_ACTION_INPUT_ShowOutput: ${{ inputs.ShowOutput }}
76-
GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }}
67+
PSMODULE_GITHUB_SCRIPT_INPUT_Token: ${{ inputs.Token }}
68+
PSMODULE_GITHUB_SCRIPT_INPUT_ClientID: ${{ inputs.ClientID }}
69+
PSMODULE_GITHUB_SCRIPT_INPUT_PrivateKey: ${{ inputs.PrivateKey }}
70+
PSMODULE_GITHUB_SCRIPT_INPUT_Debug: ${{ inputs.Debug }}
71+
PSMODULE_GITHUB_SCRIPT_INPUT_Verbose: ${{ inputs.Verbose }}
72+
PSMODULE_GITHUB_SCRIPT_INPUT_Version: ${{ inputs.Version }}
73+
PSMODULE_GITHUB_SCRIPT_INPUT_ShowInit: ${{ inputs.ShowInit }}
74+
PSMODULE_GITHUB_SCRIPT_INPUT_ShowInfo: ${{ inputs.ShowInfo }}
75+
PSMODULE_GITHUB_SCRIPT_INPUT_ShowOutput: ${{ inputs.ShowOutput }}
76+
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
7777
run: |
7878
# GitHub-Script
7979
try {

scripts/info.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ process {
1212
try {
1313
$fenceTitle = 'GitHub-Script'
1414

15-
Write-Debug "[$scriptName] - ShowInfo: $env:GITHUB_ACTION_INPUT_ShowInfo"
16-
if ($env:GITHUB_ACTION_INPUT_ShowInfo -ne 'true') {
15+
Write-Debug "[$scriptName] - ShowInfo: $env:PSMODULE_GITHUB_SCRIPT_INPUT_ShowInfo"
16+
if ($env:PSMODULE_GITHUB_SCRIPT_INPUT_ShowInfo -ne 'true') {
1717
return
1818
}
1919

@@ -28,11 +28,11 @@ process {
2828
$context = Get-GitHubContext
2929
$context | Format-List
3030

31-
Write-Verbose "Token? [$([string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token))]"
31+
Write-Verbose "Token? [$([string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_Token))]"
3232
Write-Verbose "AuthType? [$($context.AuthType)] - [$($context.AuthType -ne 'APP')]"
33-
Write-Verbose "gh auth? [$($context.AuthType -ne 'APP' -and -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token))]"
33+
Write-Verbose "gh auth? [$($context.AuthType -ne 'APP' -and -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_Token))]"
3434

35-
if ($context.AuthType -ne 'APP' -and -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token)) {
35+
if ($context.AuthType -ne 'APP' -and -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_Token)) {
3636
Write-Output 'GitHub CLI status:'
3737
$before = $LASTEXITCODE
3838
gh auth status
@@ -60,6 +60,6 @@ process {
6060

6161
end {
6262
Write-Debug "[$scriptName] - End"
63-
$DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
64-
$VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
63+
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
64+
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
6565
}

scripts/init.ps1

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ process {
1010
try {
1111
$env:PSMODULE_GITHUB_SCRIPT = $true
1212
$fenceTitle = 'GitHub-Script'
13-
$showInit = $env:GITHUB_ACTION_INPUT_ShowInit -eq 'true'
13+
$showInit = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ShowInit -eq 'true'
1414

15-
Write-Debug "[$scriptName] - ShowInit: $env:GITHUB_ACTION_INPUT_ShowInit"
15+
Write-Debug "[$scriptName] - ShowInit: $env:PSMODULE_GITHUB_SCRIPT_INPUT_ShowInit"
1616

1717
if ($showInit) {
1818
$fenceStart = "┏━━┫ $fenceTitle - Init ┣━━━━━━━━┓"
1919
Write-Output $fenceStart
2020
Write-Output '::group:: - Install GitHub PowerShell module'
2121
}
2222
$Name = 'GitHub'
23-
$Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version
24-
$Prerelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true'
23+
$Version = [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_Version) ? $null : $env:PSMODULE_GITHUB_SCRIPT_INPUT_Version
24+
$Prerelease = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease -eq 'true'
2525

2626
$alreadyInstalled = Get-InstalledPSResource -Name $Name -ErrorAction SilentlyContinue
2727
if ($Version) {
@@ -73,9 +73,9 @@ process {
7373
Import-Module -Name $Name
7474
}
7575

76-
$providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token)
77-
$providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID)
78-
$providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey)
76+
$providedToken = -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_Token)
77+
$providedClientID = -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_ClientID)
78+
$providedPrivateKey = -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_PrivateKey)
7979
$moduleStatus = [pscustomobject]@{
8080
Name = $Name
8181
Version = [string]::IsNullOrEmpty($Version) ? 'latest' : $Version
@@ -93,9 +93,18 @@ process {
9393
Write-Output '::group:: - Connect to GitHub'
9494
}
9595
if ($providedClientID -and $providedPrivateKey) {
96-
Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent:(-not $showInit)
96+
$params = @{
97+
ClientID = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ClientID
98+
PrivateKey = $env:PSMODULE_GITHUB_SCRIPT_INPUT_PrivateKey
99+
Silent = (-not $showInit)
100+
}
101+
Connect-GitHub @params
97102
} elseif ($providedToken) {
98-
Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent:(-not $showInit)
103+
$params = @{
104+
Token = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Token
105+
Silent = (-not $showInit)
106+
}
107+
Connect-GitHub @params
99108
}
100109
if ($showInit) {
101110
Write-Output '::endgroup::'

scripts/outputs.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Write-Debug "[$scriptName] - Start"
1111
try {
1212
$fenceTitle = 'GitHub-Script'
1313

14-
Write-Debug "[$scriptName] - ShowOutput: $env:GITHUB_ACTION_INPUT_ShowOutput"
15-
if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') {
14+
Write-Debug "[$scriptName] - ShowOutput: $env:PSMODULE_GITHUB_SCRIPT_INPUT_ShowOutput"
15+
if ($env:PSMODULE_GITHUB_SCRIPT_INPUT_ShowOutput -ne 'true') {
1616
return
1717
}
1818

0 commit comments

Comments
 (0)