【Github】Github Actions ~ Self-hosted runners / 設定関連 ~

◾️はじめに

Self-hosted runnersの設定について、徐々にメモっていく。

目次

【0】Self-hosted runnersの設定
【1】設定 を削除するには
【2】更新を無効にするには ~ --disableupdate ~
【3】タグを設定するには ~ --labels ~

【0】Self-hosted runnersの設定

Options Explanations Memo
--unattended インタラクティブモードを無効化 通常実行だといくつか質問形式的でコマンドを求められるがそれを無効化するオプション
--url <REPOSITORY_URL> Github repository URLを指定
--token <REGISTRATION_TOKEN> トークンを指定
--name <RUNNER_NAME> Runner名 デフォルトはマシン名 / myrunner
--runnergroup <RUNNER_GP> Runnerグループ
--labels タグを設定する 複数の場合、カンマ区切り。詳細は「【3】タグを設定するには」参照
--no-default-labels デフォルトラベル(self-hostedなど)の無効化
--local ローカルマシンからランナー設定ファイルを削除。removeコマンドのオプションとして使用
--work <WORK_DIR> 作業ディレクト
--replace 上書き
--pat Github Personal Access Token(=PAT)。実行時にネットワーク接続性をチェックするために使用
--disableupdate Self-hosted runnerの最新バージョンへの自動アップデートを無効にする 「【2】更新を無効にするには」参照
--ephemeral ランナーが1つのジョブだけを引き受けるように設定し、ジョブが終了した後にサービスがランナーの設定を解除する(詳細はhttps://zenn.dev/korosuke613/scraps/7f6fb33da4e632 cf. ephemeral(エフェメラル)=一時的な,つかの間の

https://github.com/actions/runner/blob/fde5227fbfe9c61b7861cc959ebbbba62af4754b/src/Runner.Listener/Runner.cs#L727

より抜粋

Config Options:
 --unattended           Disable interactive prompts for missing arguments. Defaults will be used for missing options
 --url string           Repository to add the runner to. Required if unattended
 --token string         Registration token. Required if unattended
 --name string          Name of the runner to configure (default {Environment.MachineName ?? "myrunner"})
 --runnergroup string   Name of the runner group to add this runner to (defaults to the default runner group)
 --labels string        Custom labels that will be added to the runner. This option is mandatory if --no-default-labels is used.
 --no-default-labels    Disables adding the default labels: 'self-hosted,{Constants.Runner.Platform},{Constants.Runner.PlatformArchitecture}'
 --local                Removes the runner config files from your local machine. Used as an option to the remove command
 --work string          Relative runner work directory (default {Constants.Path.WorkDirectory})
 --replace              Replace any existing runner with the same name (default false)
 --pat                  GitHub personal access token with repo scope. Used for checking network connectivity when executing `.{separator}run.{ext} --check`
 --disableupdate        Disable self-hosted runner automatic update to the latest released version`
 --ephemeral            Configure the runner to only take one job and then let the service un-configure the runner after the job finishes (default false)");

【1】設定 を削除するには

https://zenn.dev/ykws/scraps/c65c13f458d1c2#comment-2e81f10bb4c794

でも書かれているが、Tokenを再設定しようとすると、
〜〜〜〜
Cannot configure the runner because it is already configured.
To reconfigure the runner, run 'config.cmd remove'
 or './config.sh remove' first.
〜〜〜〜
って言われたので、「./config.sh remove」した。

ただ、それだとエラーになるので、以下のサイトを参考に
以下「対応案」で対応した。

https://qiita.com/okaponta_/items/b3eda8181a07c43baf7c
対応案

./svc.sh stop
sudo ./svc.sh uninstall
rm .runner
./config.sh remove

【2】更新を無効にするには ~ --disableupdate ~

* 以下の関連記事を参照のこと

Github Actions ~ Self-hosted runners / 自動更新OFF ~   https://dk521123.hatenablog.com/entry/2025/01/08/201947

【3】タグを設定するには ~ --labels ~

https://docs.github.com/ja/actions/hosting-your-own-runners/managing-self-hosted-runners/using-labels-with-self-hosted-runners#programmatically-assign-labels

./config.sh --url <REPOSITORY_URL> ¥
--token <REGISTRATION_TOKEN> --labels gpu

# 複数の場合
./config.sh --url <REPOSITORY_URL> ¥
--token <REGISTRATION_TOKEN> --labels gpu,x64,linux

参考文献

https://qiita.com/h_tyokinuhata/items/7a9297f75d0513572f4a

関連記事

Github Actions ~ Self-hosted runners / 入門編 ~
https://dk521123.hatenablog.com/entry/2023/12/18/204119
Github Actions ~ Self-hosted runners / あれこれ編 ~
https://dk521123.hatenablog.com/entry/2024/02/07/002736
Github Actions ~ Self-hosted runners / 自動更新OFF ~   https://dk521123.hatenablog.com/entry/2025/01/08/201947