Skip to content

Commit 9f94733

Browse files
feat: add Name input parameter to action and update main script to handle it
1 parent 92a9213 commit 9f94733

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ branding:
66
color: blue
77

88
inputs:
9+
Name:
10+
description: Name of the module.
11+
required: false
912
SettingsPath:
1013
description: Path to the settings file (json, yaml/yml, or psd1)
1114
required: false
@@ -41,6 +44,7 @@ runs:
4144
uses: PSModule/GitHub-Script@8b9d2739d6896975c0e5448d2021ae2b94b6766a # v1.7.6
4245
id: Get-PSModuleSettings
4346
env:
47+
PSMODULE_GET_SETTINGS_INPUT_Name: ${{ inputs.Name }}
4448
PSMODULE_GET_SETTINGS_INPUT_SettingsPath: ${{ inputs.SettingsPath }}
4549
PSMODULE_GET_SETTINGS_INPUT_Debug: ${{ inputs.Debug }}
4650
PSMODULE_GET_SETTINGS_INPUT_Verbose: ${{ inputs.Verbose }}

scripts/main.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'powershell-yaml', 'Hashtable' | Install-PSResource -Repository PSGallery -TrustRepository
22

3+
$name = $env:PSMODULE_GET_SETTINGS_INPUT_Name
34
$settingsPath = $env:PSMODULE_GET_SETTINGS_INPUT_SettingsPath
45
$debug = $env:PSMODULE_GET_SETTINGS_INPUT_Debug
56
$verbose = $env:PSMODULE_GET_SETTINGS_INPUT_Verbose
@@ -10,6 +11,7 @@ $workingDirectory = $env:PSMODULE_GET_SETTINGS_INPUT_WorkingDirectory
1011
LogGroup 'Inputs' {
1112
[pscustomobject]@{
1213
PWD = (Get-Location).Path
14+
Name = $name
1315
SettingsPath = $settingsPath
1416
} | Format-List | Out-String
1517
}
@@ -71,17 +73,20 @@ if (![string]::IsNullOrEmpty($settingsPath) -and (Test-Path -Path $settingsPath)
7173

7274
LogGroup 'Name' {
7375
[pscustomobject]@{
76+
InputName = $name
7477
SettingsName = $settings.Name
7578
RepositoryName = $env:GITHUB_REPOSITORY_NAME
7679
} | Format-List | Out-String
7780

78-
if (![string]::IsNullOrEmpty($settings.Name)) {
81+
if (![string]::IsNullOrEmpty($name)) {
82+
Write-Host "Using name from input parameter: [$name]"
83+
} elseif (![string]::IsNullOrEmpty($settings.Name)) {
7984
$name = $settings.Name
85+
Write-Host "Using name from settings file: [$name]"
8086
} else {
8187
$name = $env:GITHUB_REPOSITORY_NAME
88+
Write-Host "Using repository name: [$name]"
8289
}
83-
84-
Write-Host "Using [$name] as the module name."
8590
}
8691

8792
$settings = [pscustomobject]@{

0 commit comments

Comments
 (0)