更新 Service:GiteaRunner

2026-06-11 03:46:56 +00:00
parent 13b4edea57
commit 40f1a79994
+79 -75
@@ -1,75 +1,79 @@
# 簡介 # 簡介
Gitea Runneract_runner)負責執行 Gitea Actions 的 CI/CD 工作流程,需向 Gitea 主機註冊後才能接收任務。本文記錄在 Ubuntu 上以二進位檔搭配 systemd 部署 Runner 的步驟。 Gitea Runneract_runner)負責執行 Gitea Actions 的 CI/CD 工作流程,需向 Gitea 主機註冊後才能接收任務。本文記錄在 Ubuntu 上以二進位檔搭配 systemd 部署 Runner 的步驟。
# 安裝相依套件 # 安裝相依套件
部分 Actions 工作流程需要 Node.js 環境。 部分 Actions 工作流程需要 Node.js 環境。
```bash ```bash
apt update && apt install -y nodejs apt update && apt install -y nodejs
``` ```
# 下載 Gitea Runner # 下載 Gitea Runner
從官方下載指定版本的二進位檔,放到 `/usr/local/bin/runner` 從官方下載指定版本的二進位檔,放到 `/usr/local/bin/runner`
```bash ```bash
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.2/gitea-runner-1.0.2-linux-amd64 -O /usr/local/bin/runner
``` ```
下載後將 runner 設定為可執行檔。 ```bash
wget https://gitea.com/gitea/runner/releases/download/v1.0.8/gitea-runner-1.0.8-linux-amd64 -O /usr/local/bin/runner
```bash ```
chmod +x /usr/local/bin/runner
``` 下載後將 runner 設定為可執行檔。
# 註冊 Gitea Runner ```bash
chmod +x /usr/local/bin/runner
執行註冊指令,依提示輸入 Gitea 主機位址與註冊權杖(registration token),完成後會在當前目錄產生設定檔。 ```
```bash # 註冊 Gitea Runner
runner register
``` 執行註冊指令,依提示輸入 Gitea 主機位址與註冊權杖(registration token),完成後會在當前目錄產生設定檔。
# 建立 Gitea Runner 服務 ```bash
runner register
以 systemd 管理 Runner,可開機自動啟動、崩潰時自動重啟。先建立服務設定檔。 ```
```bash # 建立 Gitea Runner 服務
nano /etc/systemd/system/runner.service
``` 以 systemd 管理 Runner,可開機自動啟動、崩潰時自動重啟。先建立服務設定檔。
服務檔內容如下: ```bash
nano /etc/systemd/system/runner.service
```ini ```
[Unit]
Description=Gitea Actions runner 服務檔內容如下:
[Service] ```ini
Environment=HOME=/root [Unit]
Type=simple Description=Gitea Actions runner
WorkingDirectory=/root
ExecStart=/usr/local/bin/runner daemon [Service]
Restart=always Environment=HOME=/root
User=root Type=simple
WorkingDirectory=/root
[Install] ExecStart=/usr/local/bin/runner daemon
WantedBy=multi-user.target Restart=always
``` User=root
# 啟動服務 [Install]
WantedBy=multi-user.target
重新載入 systemd 設定、設為開機自動啟動、啟動服務並檢視狀態。 ```
```bash # 啟動服務
systemctl daemon-reload && systemctl enable runner.service && systemctl start runner.service && systemctl status runner.service
``` 重新載入 systemd 設定、設為開機自動啟動、啟動服務並檢視狀態。
# 停止服務 ```bash
systemctl daemon-reload && systemctl enable runner.service && systemctl start runner.service && systemctl status runner.service
停止並移除舊版(act_runner)服務時使用。 ```
```bash # 停止服務
systemctl stop act_runner.service && systemctl disable act_runner.service && rm /etc/systemd/system/act_runner.service
``` 停止並移除舊版(act_runner)服務時使用。
```bash
systemctl stop act_runner.service && systemctl disable act_runner.service && rm /etc/systemd/system/act_runner.service
```