diff --git a/images/win/scripts/Installers/Install-Runner.ps1 b/images/win/scripts/Installers/Install-Runner.ps1 new file mode 100644 index 00000000..559875a1 --- /dev/null +++ b/images/win/scripts/Installers/Install-Runner.ps1 @@ -0,0 +1,14 @@ +################################################################################ +## File: Install-Runner.ps1 +## Desc: Install Runner for GitHub Actions +## Supply chain security: none +################################################################################ + +Write-Host "Download latest Runner for GitHub Actions" +$release = Invoke-RestMethod -Uri "https://api.github.com/repos/actions/runner/releases/latest" +$version = $release.tag_name.Trim("v") +$downloadUrl = ($release.assets.browser_download_url -ilike "*actions-runner-win-x64-${version}.zip*") | Select-Object -First 1 +New-Item -Path "C:\ProgramData\runner" -ItemType Directory +$packagePath = Start-DownloadWithRetry -Url $downloadUrl -DownloadPath "C:\ProgramData\runner" + +Invoke-PesterTests -TestFile "RunnerCache" diff --git a/images/win/scripts/Tests/RunnerCache.tests.ps1 b/images/win/scripts/Tests/RunnerCache.tests.ps1 new file mode 100644 index 00000000..8c932fb9 --- /dev/null +++ b/images/win/scripts/Tests/RunnerCache.tests.ps1 @@ -0,0 +1,7 @@ +Describe "RunnerCache" { + Context "runner cache directory not empty" { + It "C:\ProgramData\runner" { + (Get-ChildItem -Path "C:\ProgramData\runner\*.zip" -Recurse).Count | Should -BeGreaterThan 0 + } + } +} diff --git a/images/win/windows2019.json b/images/win/windows2019.json index c00ac5d5..dea37bf8 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -173,7 +173,8 @@ "{{ template_dir }}/scripts/Installers/Install-Docker-WinCred.ps1", "{{ template_dir }}/scripts/Installers/Install-Docker-Compose.ps1", "{{ template_dir }}/scripts/Installers/Install-PowershellCore.ps1", - "{{ template_dir }}/scripts/Installers/Install-WebPlatformInstaller.ps1" + "{{ template_dir }}/scripts/Installers/Install-WebPlatformInstaller.ps1", + "{{ template_dir }}/scripts/Installers/Install-Runner.ps1" ] }, { diff --git a/images/win/windows2022.json b/images/win/windows2022.json index 74d2092e..1ab93251 100644 --- a/images/win/windows2022.json +++ b/images/win/windows2022.json @@ -158,7 +158,8 @@ "{{ template_dir }}/scripts/Installers/Install-Docker-WinCred.ps1", "{{ template_dir }}/scripts/Installers/Install-Docker-Compose.ps1", "{{ template_dir }}/scripts/Installers/Install-PowershellCore.ps1", - "{{ template_dir }}/scripts/Installers/Install-WebPlatformInstaller.ps1" + "{{ template_dir }}/scripts/Installers/Install-WebPlatformInstaller.ps1", + "{{ template_dir }}/scripts/Installers/Install-Runner.ps1" ] }, {