diff --git a/6.2-GiteaRunner%EF%BC%88Ubuntu%EF%BC%89.md b/6.2-GiteaRunner%EF%BC%88Ubuntu%EF%BC%89.md new file mode 100644 index 0000000..4fcea56 --- /dev/null +++ b/6.2-GiteaRunner%EF%BC%88Ubuntu%EF%BC%89.md @@ -0,0 +1,94 @@ +# GiteaRunner(Ubuntu) + +> 第6章 開發與持續整合 · 來源:JSC 知識庫 + +## 簡介 + +Gitea Runner(act_runner)負責執行 Gitea Actions 的 CI/CD 工作流程,需向 Gitea 主機註冊後才能接收任務。本文記錄在 Ubuntu 上以二進位檔搭配 systemd 部署 Runner 的步驟。 + +## 步驟 + +### 1. 安裝相依套件 + +部分 Actions 工作流程需要 Node.js 環境。 + +```bash +apt update && apt install -y nodejs +``` + +### 2. 下載 Gitea Runner + +從官方下載指定版本的二進位檔,放到 `/usr/local/bin/runner`。 + +```bash +wget https://gitea.com/gitea/runner/releases/download/v5.2.4/gitea-runner-5.2.4-linux-amd64 -O /usr/local/bin/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 +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 +chmod +x /usr/local/bin/runner +``` + +### 3. 註冊 Gitea Runner + +執行註冊指令,依提示輸入 Gitea 主機位址與註冊權杖(registration token),完成後會在當前目錄產生設定檔。 + +```bash +runner register +``` + +### 4. 建立 Gitea Runner 服務 + +以 systemd 管理 Runner,可開機自動啟動、崩潰時自動重啟。先建立服務設定檔。 + +```bash +nano /etc/systemd/system/runner.service +``` + +服務檔內容如下: + +```ini +[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 +``` + +### 5. 啟動服務 + +重新載入 systemd 設定、設為開機自動啟動、啟動服務並檢視狀態。 + +```bash +systemctl daemon-reload && systemctl enable runner.service && systemctl start runner.service && systemctl status runner.service +``` + +### 6. 停止服務 + +停止並移除舊版(act_runner)服務時使用。 + +```bash +systemctl stop act_runner.service && systemctl disable act_runner.service && rm /etc/systemd/system/act_runner.service +``` + + +--- + +[← 6.1 Gitea](6.1-Gitea) · [本章目錄](%E7%AC%AC6%E7%AB%A0-%E9%96%8B%E7%99%BC%E8%88%87%E6%8C%81%E7%BA%8C%E6%95%B4%E5%90%88) · [全書目錄](Home) · [6.3 Gitea Runner(Windows) →](6.3-Gitea-Runner)