-
Notifications
You must be signed in to change notification settings - Fork 2
Windows GitHub Actions Runner
Javier Romero edited this page Mar 8, 2021
·
41 revisions
- Provider: equinix metal
- Access: see https://github.com/buildpacks/ci/tree/main/gh-runners/windows
- Package Manager: chocolatey
In a new Administrator Powershell terminal:
# Install chocolately (https://chocolatey.org/install)
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install dependencies; Note: for Windows 2016, use `choco install docker-desktop --version=2.0.0.3`
choco install docker-desktop git make cygwin -y
# Exit and start a new terminal to reload `$env:PATH`
Exit
In a new Administrator Powershell terminal:
# Set up Github Actions Runner Process
## IMPORTANT:
## Each runner is specific to only one git repository. To reuse the same VM, you must run a service per repo.
## Convention is to install each runner in a directory named after the repo. eg. `\actions-runners\pack\`
Set-Variable -Name REPO -Value pack
mkdir \actions-runners\$REPO; cd \actions-runners\$REPO
curl.exe -Lo actions-runner-win-x64-2.168.0.zip https://github.com/actions/runner/releases/download/v2.168.0/actions-runner-win-x64-2.168.0.zip
Expand-Archive actions-runner-win-x64-2.168.0.zip
# Disable automatic CRLF
git config --global core.autocrlf false
# Add cygwin binaries path
[Environment]::SetEnvironmentVariable("PATH", "$ENV:PATH;C:\tools\cygwin\bin", "USER")
# Install Hyper-V for Docker; NOTE: This will restart the machine.
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
- Enable C: drive sharing for volume mounting:
- On Windows 2016,
Docker Desktop
-> Right click Settings -> Shared Drives -> Check C - On Windows 2019,
Docker Desktop
-> Right click Settings -> Resources -> File Sharing -> Check C
- On Windows 2016,
In an Administrator Powershell terminal:
# Get the runner's internal IP address (it should start with `10.`)
$IPAddress=(Get-NetIPAddress -InterfaceAlias bond0 -AddressFamily IPv4)[1].IPAddress
"# Modified by CNB: https://github.com/buildpacks/ci/wiki/Windows-GitHub-Actions-Runner#for-wcow-only
${IPAddress} host.docker.internal
${IPAddress} gateway.docker.internal
" | Out-File -Filepath C:\Windows\System32\drivers\etc\hosts -Encoding utf8
-
In Docker settings, add
"10.0.0.0/8"
to theinsecure-registries
list (Docker should restart after applying).
- Configure:
- In a browser, go to
https://github.com/buildpacks/{{REPO}}/settings/actions
- Click Add Runner
- Run configure step in
PowerShell
- Set
name
to the hostname of the worker - Set Y when asked to run as Service
- When asked what user to run the service as, open another terminal and type
whoami
, that's the value you want to use
- When asked what user to run the service as, open another terminal and type
- Leave other options as their default
- Set
- Add appropriate labels
- In a browser, go to
These labels should be added to runners that then may be refrered to by the GitHub workflows:
-
wcow
- Docker configured with Windows Containers on Windows
Example usage:
jobs:
test:
runs-on: [self-hosted, windows, wcow]
If tests begin to fail for Docker-related issues, try the following:
- Restart Docker (use taskbar icon, not command line)
- Double check that
c:\windows\system32\drivers\etc\hosts
entries forhost.docker.internal
andgateway.docker.internal
are correct (a Docker update or restart may overwrite changes) - Restart runner service:
Restart-Service "actions.runner*
- Restart runner machine