Skip to content

Commit f1008b1

Browse files
🪲 [Fix]: Access to GH_TOKEN and Get-Settings for Name (#171)
## Description This pull request includes updates to the workflow files to improve clarity and functionality. The changes primarily focus on refining conditional logic in PowerShell scripts and enhancing environment variable handling in GitHub Actions. ### Workflow improvements: * [`.github/workflows/Get-Settings.yml`](diffhunk://#diff-68f351d419a9b4db4797434891d5dfad44d83de65bfee7ba1c60badae369dbefL134-R140): Updated the conditional logic for determining the `$name` variable to use explicit `if-elseif-else` statements, improving readability and maintainability. ### Environment variable and input adjustments: * [`.github/workflows/workflow.yml`](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1R289-L297): Added the `GH_TOKEN` environment variable to the `Publish module` step to ensure authentication is handled securely. * [`.github/workflows/workflow.yml`](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1R305): Reintroduced the `WorkingDirectory` input to the `Publish module` step for better modularity and flexibility in specifying paths. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [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 f5eba0b commit f1008b1

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.github/workflows/Get-Settings.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ jobs:
131131
RepositoryName = $env:GITHUB_REPOSITORY_NAME
132132
} | Format-List | Out-String
133133
134-
$name = ![string]::IsNullOrEmpty($inputName) ? $name : ![string]::IsNullOrEmpty($settings.Name) ? $settings.Name : $env:GITHUB_REPOSITORY_NAME
134+
if (![string]::IsNullOrEmpty($inputName)) {
135+
$name = $inputName
136+
} elseif (![string]::IsNullOrEmpty($settings.Name)) {
137+
$name = $settings.Name
138+
} else {
139+
$name = $env:GITHUB_REPOSITORY_NAME
140+
}
135141
136142
Write-Host "Using [$name] as the module name."
137143
}

.github/workflows/workflow.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,13 @@ jobs:
286286
287287
- name: Publish module
288288
uses: PSModule/Publish-PSModule@v2
289+
env:
290+
GH_TOKEN: ${{ github.token }}
289291
with:
290292
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
291-
ModulePath: ${{ inputs.WorkingDirectory }}/outputs/module
293+
ModulePath: outputs/module
292294
APIKey: ${{ secrets.APIKEY }}
293295
WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }}
294-
Debug: ${{ inputs.Debug }}
295-
Prerelease: ${{ inputs.Prerelease }}
296-
Verbose: ${{ inputs.Verbose }}
297-
Version: ${{ inputs.Version }}
298296
AutoCleanup: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.AutoCleanup }}
299297
AutoPatching: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.AutoPatching }}
300298
DatePrereleaseFormat: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.DatePrereleaseFormat }}
@@ -304,3 +302,4 @@ jobs:
304302
MinorLabels: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.MinorLabels }}
305303
PatchLabels: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.PatchLabels }}
306304
VersionPrefix: ${{ fromJson(needs.Get-Settings.outputs.Settings).Publish.Module.VersionPrefix }}
305+
WorkingDirectory: ${{ inputs.WorkingDirectory }}

0 commit comments

Comments
 (0)