Add Windows runner profiles and configuration for Gitea CI

- Introduced Dockerfiles for various Windows runner profiles: C/C++, .NET, Go, and MSYS.
- Added a PowerShell script to start the Gitea runner with appropriate configurations.
- Updated Ansible host variables to include new Windows build root and runner configurations.
- Enhanced the Windows Gitea runner role to support multiple execution modes (linux_podman and windows_mcr).
- Implemented tasks to validate runner execution modes, ensure necessary services are running, and manage Docker containers for Windows runners.
- Created a new task file for managing Windows-specific runner operations.
- Updated the configuration template to dynamically set paths for runner files and cache directories.
This commit is contained in:
2026-07-03 00:18:20 +02:00
parent e59a832d5d
commit c4d1db3a91
12 changed files with 920 additions and 6 deletions
@@ -0,0 +1,22 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2022
SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# Base image for Windows Gitea runners with Git for Windows tools and gitea runner.
ARG ACT_RUNNER_VERSION=2.0.0
RUN Set-StrictMode -Version Latest; \
$ErrorActionPreference = 'Stop'; \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')); \
choco config set commandExecutionTimeoutSeconds 14400; \
choco feature disable -n showDownloadProgress; \
choco feature enable -n allowGlobalConfirmation; \
choco install git --yes --no-progress --limit-output; \
New-Item -ItemType Directory -Path C:\gitea-runner -Force | Out-Null; \
$runnerUrl = 'https://gitea.com/gitea/runner/releases/download/v{0}/gitea-runner-{0}-windows-amd64.exe' -f $env:ACT_RUNNER_VERSION; \
Invoke-WebRequest -UseBasicParsing -Uri $runnerUrl -OutFile C:\gitea-runner\act_runner.exe
COPY ["start-runner.ps1", "C:/gitea-runner/start-runner.ps1"]
ENV PATH="C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps"
ENTRYPOINT ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "C:\\gitea-runner\\start-runner.ps1"]
@@ -0,0 +1,9 @@
FROM local/gitea-windows-runner:windows-base
SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# C/C++ profile with cmake and ninja.
RUN choco feature enable -n allowGlobalConfirmation; \
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'; \
choco install ninja; \
choco clean --yes
@@ -0,0 +1,8 @@
FROM local/gitea-windows-runner:windows-base
SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# .NET profile for building and testing managed workloads.
RUN choco feature enable -n allowGlobalConfirmation; \
choco install dotnet-sdk --version=8.0.204; \
choco clean --yes
@@ -0,0 +1,8 @@
FROM local/gitea-windows-runner:windows-base
SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# Go profile for Windows builds.
RUN choco feature enable -n allowGlobalConfirmation; \
choco install golang --version=1.22.4; \
choco clean --yes
@@ -0,0 +1,7 @@
FROM local/gitea-windows-runner:windows-base
SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
# MSYS-focused profile with common GNU toolchain extras.
RUN choco feature enable -n allowGlobalConfirmation; \
choco install make msys2 unzip --yes --no-progress --limit-output
@@ -0,0 +1,17 @@
$ErrorActionPreference = "Stop"
$runner = "C:\gitea-runner\act_runner.exe"
$config = if ($env:CONFIG_FILE) { $env:CONFIG_FILE } else { "C:\runner-data\config.yaml" }
$runnerFile = if ($env:GITEA_RUNNER_FILE) { $env:GITEA_RUNNER_FILE } else { "C:\runner-data\.runner" }
if (-not (Test-Path -Path $runnerFile) -and $env:GITEA_INSTANCE_URL -and $env:GITEA_RUNNER_REGISTRATION_TOKEN) {
$labels = if ($env:GITEA_RUNNER_LABELS) { $env:GITEA_RUNNER_LABELS } else { "windows:host" }
$name = if ($env:GITEA_RUNNER_NAME) { $env:GITEA_RUNNER_NAME } else { $env:COMPUTERNAME }
& $runner register --no-interactive --instance $env:GITEA_INSTANCE_URL --token $env:GITEA_RUNNER_REGISTRATION_TOKEN --name $name --labels $labels --config $config
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}
& $runner daemon --config $config
exit $LASTEXITCODE