From d17d9c2d6ce0b08e5a0a3aea4423486cb80258d4 Mon Sep 17 00:00:00 2001 From: mullayanov Date: Thu, 17 Apr 2025 22:26:47 +0500 Subject: [PATCH] re-registration fix --- Dockerfile | 3 +++ entrypoint.ps1 | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index c463cb9..deb049b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,5 +35,8 @@ RUN [Environment]::SetEnvironmentVariable(\"Path\", $env:Path + \";C:\Program Fi ARG RUNNER_VERSION="0.2.11" ADD https://gitea.com/gitea/act_runner/releases/download/v$RUNNER_VERSION/act_runner-$RUNNER_VERSION-windows-amd64.exe act_runner.exe +RUN New-Item -ItemType Directory -Force -Path "C:\actions-runner\data" | Out-Null +VOLUME C:/actions-runner/data + COPY entrypoint.ps1 . ENTRYPOINT ["pwsh.exe", ".\\entrypoint.ps1"] \ No newline at end of file diff --git a/entrypoint.ps1 b/entrypoint.ps1 index 7cf8411..f0448b8 100644 --- a/entrypoint.ps1 +++ b/entrypoint.ps1 @@ -1,8 +1,8 @@ # Set the labels if given if ($null -ne $env:GITEA_RUNNER_LABELS) { - $LABELS = $env:GITEA_RUNNER_LABELS + $LABELS = $env:GITEA_RUNNER_LABELS } else { - $LABELS = 'windows:host' + $LABELS = 'windows:host,windows-msbuild:host' } $GITEA_RUNNER_NAME = $env:GITEA_RUNNER_NAME @@ -10,13 +10,19 @@ $GITEA_INSTANCE_URL = $env:GITEA_INSTANCE_URL $GITEA_RUNNER_REGISTRATION_TOKEN = $env:GITEA_RUNNER_REGISTRATION_TOKEN try { - Write-Host "Configuring runner: $GITEA_RUNNER_NAME" - ./act_runner.exe register --no-interactive --instance $GITEA_INSTANCE_URL --token $GITEA_RUNNER_REGISTRATION_TOKEN --name $GITEA_RUNNER_NAME --labels $LABELS + Push-Location "data" + + # Check if runner is already registered + if (-not (Test-Path -Path "data/.runner")) { + Write-Host "Configuring new runner: $GITEA_RUNNER_NAME" + ../act_runner.exe register --no-interactive --instance $GITEA_INSTANCE_URL --token $GITEA_RUNNER_REGISTRATION_TOKEN --name $GITEA_RUNNER_NAME --labels $LABELS + } - # Remove access token for security reasons - $env:ACCESS_TOKEN=$null - ./act_runner.exe daemon + # Remove registration token for security reasons + $env:GITEA_RUNNER_REGISTRATION_TOKEN=$null + + ../act_runner.exe daemon } catch { - Write-Error $_.Exception.Message + Write-Error $_.Exception.Message } \ No newline at end of file