diff --git a/Service%EF%BC%9AGiteaRunner.md b/Service%EF%BC%9AGiteaRunner.md index 40046db..a7c9113 100644 --- a/Service%EF%BC%9AGiteaRunner.md +++ b/Service%EF%BC%9AGiteaRunner.md @@ -1,75 +1,79 @@ -# 簡介 - -Gitea Runner(act_runner)負責執行 Gitea Actions 的 CI/CD 工作流程,需向 Gitea 主機註冊後才能接收任務。本文記錄在 Ubuntu 上以二進位檔搭配 systemd 部署 Runner 的步驟。 - -# 安裝相依套件 - -部分 Actions 工作流程需要 Node.js 環境。 - -```bash -apt update && apt install -y nodejs -``` - -# 下載 Gitea Runner - -從官方下載指定版本的二進位檔,放到 `/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 -``` - -# 註冊 Gitea Runner - -執行註冊指令,依提示輸入 Gitea 主機位址與註冊權杖(registration token),完成後會在當前目錄產生設定檔。 - -```bash -runner register -``` - -# 建立 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 -``` - -# 啟動服務 - -重新載入 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 -``` +# 簡介 + +Gitea Runner(act_runner)負責執行 Gitea Actions 的 CI/CD 工作流程,需向 Gitea 主機註冊後才能接收任務。本文記錄在 Ubuntu 上以二進位檔搭配 systemd 部署 Runner 的步驟。 + +# 安裝相依套件 + +部分 Actions 工作流程需要 Node.js 環境。 + +```bash +apt update && apt install -y nodejs +``` + +# 下載 Gitea Runner + +從官方下載指定版本的二進位檔,放到 `/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 +``` + +```bash +wget https://gitea.com/gitea/runner/releases/download/v1.0.8/gitea-runner-1.0.8-linux-amd64 -O /usr/local/bin/runner +``` + +下載後將 runner 設定為可執行檔。 + +```bash +chmod +x /usr/local/bin/runner +``` + +# 註冊 Gitea Runner + +執行註冊指令,依提示輸入 Gitea 主機位址與註冊權杖(registration token),完成後會在當前目錄產生設定檔。 + +```bash +runner register +``` + +# 建立 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 +``` + +# 啟動服務 + +重新載入 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 +```