Skip to content

Commit df5f583

Browse files
committed
Update workflow
1 parent 30a953e commit df5f583

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/workflows/publish-psg-module.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ jobs:
1212
steps:
1313
- name: "Checkout Repository"
1414
uses: "actions/[email protected]"
15-
- name: "Change PowerShell Gallery Installation Policy"
15+
- name: "Modify PowerShell Gallery Installation Policy"
16+
id: "psgip"
1617
run: |
17-
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
18+
Write-Host -Object "::set-output name=installationpolicy::$((Get-PSRepository -Name PSGallery).InstallationPolicy)"
19+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
1820
shell: "pwsh"
19-
- name: "Install PowerShellGet"
21+
- name: "Setup PowerShellGet"
2022
run: |
21-
Install-Module -AcceptLicense -Name PowerShellGet -Scope AllUsers -Verbose
23+
if (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.2.5 -ErrorAction SilentlyContinue) {} else {
24+
Install-Module -AcceptLicense -Name PowerShellGet -Scope AllUsers -Verbose
25+
}
2226
shell: "pwsh"
2327
- name: "Update PowerShell Modules"
2428
run: |
@@ -32,3 +36,8 @@ jobs:
3236
run: |
3337
Publish-Module -Path .\hugoalh.GitHubActionsToolkit\ -NugetAPIKey '${{secrets.POWERSHELLGALLERY_TOKEN}}' -Verbose
3438
shell: "pwsh"
39+
- name: "Revert Modify PowerShell Gallery Installation Policy"
40+
if: "${{steps.psgip.outcome == 'success' && always()}}"
41+
run: |
42+
Set-PSRepository -Name PSGallery -InstallationPolicy '${{steps.psgip.outputs.installationpolicy}}'
43+
shell: "pwsh"

0 commit comments

Comments
 (0)