From c6f9fded68fbe7021d781f5630bbad77854e3777 Mon Sep 17 00:00:00 2001 From: David Dashti <47575784+Dashtid@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:08:09 +0200 Subject: [PATCH] fix(ci): register PSGallery before trusting it The hosted runner image no longer ships with PSGallery pre-registered, so 'Set-PSRepository PSGallery -InstallationPolicy Trusted' now fails hard: Set-PSRepository: No repository with the name 'PSGallery' was found. This broke the PowerShell Analysis job (and would break both Pester jobs on their next run) in ci.yml - a workflow untouched by the trivy permissions fix merged in #12. Last green ci.yml run was 2026-08-04; the image changed since. Register-PSRepository -Default when PSGallery is absent, then trust it as before. Applied to all three call sites (PSScriptAnalyzer install, Windows Pester install, Linux Pester install) so the next scheduled run does not rediscover it. private-toolkit is unaffected because it calls Install-Module directly without touching the repository registration. --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bcaf7c..1b93fd8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,13 @@ jobs: shell: pwsh run: | $ErrorActionPreference = 'Stop' + # The hosted runner image no longer ships with PSGallery + # pre-registered, so Set-PSRepository fails outright with + # "No repository with the name 'PSGallery' was found". + # Register the defaults first when it is absent. + if (-not (Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue)) { + Register-PSRepository -Default + } Set-PSRepository PSGallery -InstallationPolicy Trusted $installed = Get-Module -ListAvailable -Name PSScriptAnalyzer | @@ -205,6 +212,13 @@ jobs: - name: Install Pester shell: pwsh run: | + # The hosted runner image no longer ships with PSGallery + # pre-registered, so Set-PSRepository fails outright with + # "No repository with the name 'PSGallery' was found". + # Register the defaults first when it is absent. + if (-not (Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue)) { + Register-PSRepository -Default + } Set-PSRepository PSGallery -InstallationPolicy Trusted $installed = Get-Module -ListAvailable -Name Pester | @@ -305,6 +319,13 @@ jobs: - name: Install Pester shell: pwsh run: | + # The hosted runner image no longer ships with PSGallery + # pre-registered, so Set-PSRepository fails outright with + # "No repository with the name 'PSGallery' was found". + # Register the defaults first when it is absent. + if (-not (Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue)) { + Register-PSRepository -Default + } Set-PSRepository PSGallery -InstallationPolicy Trusted Install-Module -Name Pester -MinimumVersion $env:PESTER_VERSION -Force -Scope CurrentUser Import-Module Pester -PassThru