From 23e386d1c25df14873408747bdbdd0b1f992568e Mon Sep 17 00:00:00 2001 From: Peter Shepehrd <109117968+pshepherd10@users.noreply.github.com> Date: Fri, 10 Nov 2023 11:24:16 -0500 Subject: [PATCH] add runner install script for windows image (#8671) --- images/win/scripts/Installers/Install-Runner.ps1 | 14 ++++++++++++++ images/win/scripts/Tests/RunnerCache.tests.ps1 | 7 +++++++ images/win/windows2019.json | 3 ++- images/win/windows2022.json | 3 ++- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 images/win/scripts/Installers/Install-Runner.ps1 create mode 100644 images/win/scripts/Tests/RunnerCache.tests.ps1 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" ] }, {