10
Service:GiteaRunner
系統管理員 edited this page 2026-06-11 03:46:56 +00:00
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

簡介

Gitea Runneract_runner)負責執行 Gitea Actions 的 CI/CD 工作流程,需向 Gitea 主機註冊後才能接收任務。本文記錄在 Ubuntu 上以二進位檔搭配 systemd 部署 Runner 的步驟。

安裝相依套件

部分 Actions 工作流程需要 Node.js 環境。

apt update && apt install -y nodejs

下載 Gitea Runner

從官方下載指定版本的二進位檔,放到 /usr/local/bin/runner

wget https://gitea.com/gitea/runner/releases/download/v1.0.2/gitea-runner-1.0.2-linux-amd64 -O /usr/local/bin/runner
wget https://gitea.com/gitea/runner/releases/download/v1.0.8/gitea-runner-1.0.8-linux-amd64 -O /usr/local/bin/runner

下載後將 runner 設定為可執行檔。

chmod +x /usr/local/bin/runner

註冊 Gitea Runner

執行註冊指令,依提示輸入 Gitea 主機位址與註冊權杖(registration token),完成後會在當前目錄產生設定檔。

runner register

建立 Gitea Runner 服務

以 systemd 管理 Runner,可開機自動啟動、崩潰時自動重啟。先建立服務設定檔。

nano /etc/systemd/system/runner.service

服務檔內容如下:

[Unit]
Description=Gitea Actions runner

[Service]
Environment=HOME=/root
Type=simple
WorkingDirectory=/root
ExecStart=/usr/local/bin/runner daemon
Restart=always
User=root

[Install]
WantedBy=multi-user.target

啟動服務

重新載入 systemd 設定、設為開機自動啟動、啟動服務並檢視狀態。

systemctl daemon-reload && systemctl enable runner.service && systemctl start runner.service && systemctl status runner.service

停止服務

停止並移除舊版(act_runner)服務時使用。

systemctl stop act_runner.service && systemctl disable act_runner.service && rm /etc/systemd/system/act_runner.service