gweinjc is testing PowerShell caching #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cache Dependancies Test | |
run-name: ${{ github.actor }} is testing PowerShell caching | |
on: push | |
jobs: | |
setup-build-dependancies: | |
runs-on: ubuntu-latest | |
timeout-minutes: 90 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PowerShell Module Cache | |
id: cacher | |
uses: actions/cache@v3 | |
with: | |
path: "/home/runner/.local/share/powershell/Modules/" | |
key: PS-Dependancies | |
- name: Install dependencies | |
if: steps.cacher.outputs.cache-hit != 'true' | |
shell: pwsh | |
run: | | |
Set-PSRepository PSGallery -InstallationPolicy Trusted | |
If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { | |
Write-Host ('[status]Installing package provider NuGet'); | |
Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force | |
} | |
$PSDependencies = @{ | |
'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } | |
'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } | |
'PSScriptAnalyzer' = @{Repository = 'PSGallery'; RequiredVersion = '1.19.1' } | |
'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } | |
'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } | |
'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } | |
} | |
foreach ($RequiredModule in $PSDependencies.Keys) { | |
If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { | |
Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") | |
Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force | |
} | |
} |