如何升级自托管动作运行器?

问题描述 投票:0回答:2

安装在 Linux、Windows 和 Mac 系统上的自托管 GitHub actions 运行器。

我需要将 Linux、Windows 和 MacOS 上的运行程序版本升级到最新版本。

  1. 如何查看当前安装的Runner版本?

在跑步者

log
service status
侧,我找不到信息。

  1. 如何将runner升级到最新版本?

请帮我提供信息。预先感谢。

github github-actions github-actions-self-hosted-runners github-actions-runners
2个回答
3
投票

转到自托管运行器目录,列出文件夹,您应该看到版本后缀为 bin.2.288.1、externals.2.288.1 的 bin 和 externals 目录 - 最新的应该具有带有完整目录的符号链接。您还可以在 /bin 目录 json 文件中检查每个组件侦听器、插件主机、worker 的版本。无需强制更新自托管运行器 - 它应该自动更新到最新版本。您需要手动更新运行程序的一种情况是在 docker 容器内 - 您可以使用此脚本:

https://github.com/GarnerCorp/github-actions-runner/blob/cb604618a600bd5174f3dbc8d51d15eee6585c68/scripts/install-runner


0
投票
# Enable error handling, but handle missing version file gracefully
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

# Get the directory where the script is running
$scriptDirectory = $PSScriptRoot

# Function to get the latest runner version from GitHub
function Get-LatestRunnerVersion {
    $response = Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/latest" -MaximumRedirection 0 -ErrorAction Ignore
    $locationHeader = $response.Headers.Location
    $latestVersion = $locationHeader -replace '.*/v', '' -replace '\s+', ''
    return $latestVersion
}

# Path to store the current runner version using the script's directory
$versionFilePath = Join-Path -Path $scriptDirectory -ChildPath "image_runner_version.txt"
$runnerDirectory = $scriptDirectory
$runnerDownloadPath = Join-Path -Path $scriptDirectory -ChildPath "actions-runner.zip"

# Ensure the runner directory exists (though it's likely the script directory already exists)
if (-Not (Test-Path -Path $runnerDirectory)) {
    New-Item -Path $runnerDirectory -ItemType Directory -Force
}

# Check if the version file exists and read the current version
if (Test-Path -Path $versionFilePath) {
    $imageRunnerVersion = Get-Content -Path $versionFilePath -Raw
    $imageRunnerVersion = $imageRunnerVersion.Trim()
} else {
    Write-Host "Version file does not exist, assuming the runner is not yet installed."
    $imageRunnerVersion = "<not set>"
}

# Get the latest version from GitHub
$latestRunnerVersion = Get-LatestRunnerVersion

# Check if the runner is already up to date
if ($imageRunnerVersion -eq $latestRunnerVersion) {
    Write-Host "The runner is up to date with version $imageRunnerVersion."
    exit 0
} else {
    Write-Host "Current runner version ($imageRunnerVersion) is not up to date. Latest version is $latestRunnerVersion."
}

# Download and extract the latest runner version
Write-Host "Downloading and installing the latest version ($latestRunnerVersion)..."
$downloadUrl = "https://github.com/actions/runner/releases/download/v$latestRunnerVersion/actions-runner-win-x64-$latestRunnerVersion.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $runnerDownloadPath

# Unzip the downloaded file to the script directory
Expand-Archive -Path $runnerDownloadPath -DestinationPath $runnerDirectory -Force

# Clean up the downloaded file
Remove-Item -Path $runnerDownloadPath

# After successful installation, write the version file with the latest version
Set-Content -Path $versionFilePath -Value $latestRunnerVersion

Write-Host "The runner has been updated to version $latestRunnerVersion and the version file has been updated."

这是我使用的Windows powershell更新脚本。将其放在与您的跑步者相同的目录中。

© www.soinside.com 2019 - 2024. All rights reserved.