Skip to content

Commit 449dbb0

Browse files
Align publish action credential name
Rename the Publish-PSModule action input and environment variable to PSGALLERY_API_KEY while retaining the PowerShell cmdlet parameter name. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 0ac9a29 commit 449dbb0

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

.github/actions/Publish-PSModule/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Publishes a pre-versioned PowerShell module artifact to the PowerShell Gallery.
99
| `Name` | Name of the module to publish. | No | Repository name |
1010
| `ModulePath` | Path containing the built `<Name>/` module directory. | No | `outputs/module` |
1111
| `ArtifactName` | Name of the module artifact to download. | No | `module` |
12-
| `APIKey` | PowerShell Gallery API key supplied from the caller's `PSGALLERY_API_KEY` secret. | Yes | N/A |
12+
| `PSGALLERY_API_KEY` | PowerShell Gallery API key. | Yes | N/A |
1313
| `WhatIf` | Logs publishing operations without publishing the module. | No | `false` |
1414
| `WorkingDirectory` | Directory where the publishing script runs. | No | `.` |
1515

@@ -26,7 +26,7 @@ This action does not provide outputs.
2626
Name: ExampleModule
2727
ModulePath: outputs/module
2828
ArtifactName: module
29-
APIKey: ${{ secrets.PSGALLERY_API_KEY }}
29+
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
3030
```
3131
3232
Use [Release-PSModule](../Release-PSModule/README.md) in a separate workflow step to create the GitHub release from the same artifact.

.github/actions/Publish-PSModule/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
description: Path to the folder containing the <Name>/ module subdirectory from Build-PSModule.
1111
required: false
1212
default: outputs/module
13-
APIKey:
13+
PSGALLERY_API_KEY:
1414
description: PowerShell Gallery API Key.
1515
required: true
1616
WhatIf:
@@ -49,6 +49,6 @@ runs:
4949
GH_TOKEN: ${{ env.GH_TOKEN }}
5050
PSMODULE_PUBLISH_PSMODULE_INPUT_Name: ${{ inputs.Name }}
5151
PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath: ${{ inputs.ModulePath }}
52-
PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey: ${{ inputs.APIKey }}
52+
PSMODULE_PUBLISH_PSMODULE_INPUT_PSGALLERY_API_KEY: ${{ inputs.PSGALLERY_API_KEY }}
5353
PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }}
5454
run: ${{ github.action_path }}/src/publish.ps1

.github/actions/Publish-PSModule/src/publish.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
2-
'PSUseDeclaredVarsMoreThanAssignments', 'apiKey',
2+
'PSUseDeclaredVarsMoreThanAssignments', 'psGalleryApiKey',
33
Justification = 'Variable is used in script blocks.'
44
)]
55
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
@@ -38,7 +38,7 @@ LogGroup 'Load inputs' {
3838
exit 1
3939
}
4040
$modulePath = Resolve-Path -Path $modulePathCandidate | Select-Object -ExpandProperty Path
41-
$apiKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey
41+
$psGalleryApiKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PSGALLERY_API_KEY
4242
$whatIf = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf -eq 'true'
4343

4444
Write-Host "Module name: [$name]"
@@ -138,7 +138,7 @@ LogGroup 'Publish to PSGallery' {
138138
Write-Host "Publish-PSResource -Path $modulePath -Repository PSGallery -ApiKey ***"
139139
} else {
140140
try {
141-
Publish-PSResource -Path $modulePath -Repository PSGallery -ApiKey $apiKey
141+
Publish-PSResource -Path $modulePath -Repository PSGallery -ApiKey $psGalleryApiKey
142142
} catch {
143143
Write-Error $_.Exception.Message
144144
exit 1

.github/workflows/Publish-Module.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
with:
6262
Name: ${{ fromJson(inputs.Settings).Name }}
6363
ModulePath: outputs/module
64-
APIKey: ${{ secrets.PSGALLERY_API_KEY }}
64+
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
6565
WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }}
6666
WorkingDirectory: ${{ fromJson(inputs.Settings).WorkingDirectory }}
6767

0 commit comments

Comments
 (0)