Refactor Windows Gitea runner Dockerfiles and update CI configuration

This commit is contained in:
2026-07-03 23:56:19 +02:00
parent 9a9b36cac6
commit dfeaea3283
7 changed files with 80 additions and 9 deletions
@@ -311,6 +311,19 @@
$ErrorActionPreference = "Stop"
$docker = "{{ windows_gitea_runner_windows_runtime_bin }}"
$name = "{{ __windows_gitea_runner_windows_container_name }}"
$runArgsJson = '{{ __windows_gitea_runner_windows_run_args | to_json }}'
$runArgs = @()
if (-not [string]::IsNullOrWhiteSpace($runArgsJson)) {
$parsedRunArgs = $runArgsJson | ConvertFrom-Json
if ($null -ne $parsedRunArgs) {
if ($parsedRunArgs -is [System.Array]) {
$runArgs = @($parsedRunArgs)
}
else {
$runArgs = @($parsedRunArgs)
}
}
}
if (Get-Variable -Name PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
$PSNativeCommandUseErrorActionPreference = $false
}
@@ -331,7 +344,7 @@
$env:GITEA_RUNNER_LABELS = {{ __windows_gitea_runner_windows_labels | to_json }}
& $docker run -d --name $name --restart "{{ windows_gitea_runner_windows_restart_policy }}" `
@({{ __windows_gitea_runner_windows_run_args | map('to_json') | join(', ') }}) `
@($runArgs) `
--label "{{
windows_gitea_runner_windows_container_hash_label
}}={{ __windows_gitea_runner_windows_desired_container_hash }}" `
@@ -364,6 +377,19 @@
$image = "{{ __windows_gitea_runner_windows_image }}"
$hostData = "{{ __windows_gitea_runner_windows_data_dir }}"
$hostConfig = "{{ __windows_gitea_runner_windows_runtime_config_file }}"
$runArgsJson = '{{ __windows_gitea_runner_windows_run_args | to_json }}'
$runArgs = @()
if (-not [string]::IsNullOrWhiteSpace($runArgsJson)) {
$parsedRunArgs = $runArgsJson | ConvertFrom-Json
if ($null -ne $parsedRunArgs) {
if ($parsedRunArgs -is [System.Array]) {
$runArgs = @($parsedRunArgs)
}
else {
$runArgs = @($parsedRunArgs)
}
}
}
if (Get-Variable -Name PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
$PSNativeCommandUseErrorActionPreference = $false
@@ -399,7 +425,7 @@
$diagName = "$name-diag-$([guid]::NewGuid().ToString('N').Substring(0, 8))"
$diagRun = & $docker run --rm --name $diagName `
--entrypoint "C:\Windows\System32\cmd.exe" `
@({{ __windows_gitea_runner_windows_run_args | map('to_json') | join(', ') }}) `
@($runArgs) `
--mount "type=bind,source={{ __windows_gitea_runner_windows_data_dir }},target=C:\runner-data" `
-e "CONFIG_FILE=C:\runner-data\config.yaml" `
-e "GITEA_INSTANCE_URL={{ windows_gitea_runner_windows_instance_url }}" `