Files
bot 0d5a7d8044
cd / tag (pull_request) Successful in 3s
ci / test (pull_request) Successful in 2m9s
調整:ci/cd 一致化(action-ci 自動偵測、action-cd)、版本計算抽到 next-version
2026-11-05 04:12:39 +00:00

35 lines
2.2 KiB
Markdown
Raw Permalink Blame History

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.
# deploy-go
三個步驟:檢查環境 → `go install` 指定版本 → 安裝與啟動服務;健康檢查沒通過就換回上一版。composite action,要在目標主機的 runner 上執行。
## 用法
版本由呼叫端的 Gitea Actions 變數決定(例如 `vars.ACTION_DEPLOY_GO_VERSION`),不要用分支名稱:runner 依 ref 重用舊映像檔,改了腳本不會生效,所以每次改動都發新標籤。
```yaml
- uses: https://gitea.jsc.idv.tw/actions/deploy-go@${{ vars.ACTION_DEPLOY_GO_VERSION }}
with:
version: ...
go_version: ...
```
## 輸入
|名稱|必填|預設|說明|
|---|---|---|---|
|`version`|是||要部署的確切版本,例如 v0.4.9 或 v0.5.0-dev.2|
|`token`|||套件庫需要驗證時的權杖(需要 read:package)|
|`go_version`|是||需要的 Go 版本(通常是 vars.GO_VERSION);主機的 Go 不足就下載安裝|
|`addr`|||服務不存在、要安裝時的監聽位址(通常是 vars.DEPLOY_ADDR;空=預設 0.0.0.0:8080)|
|`data`|||服務不存在、要安裝時的資料目錄(通常是 vars.DEPLOY_DATA;空=預設 /var/lib/<名稱>)|
|`name`|||應用程式名稱,決定執行檔(/usr/local/bin/<名稱>)、服務名稱、go install 的 cmd/<名稱> 與資料目錄;預設是儲存庫名稱|
|`gitea_url`||`${{ github.server_url }}`|Gitea 網址,預設是目前的 Gitea(github.server_url)|
|`gitea_repo`||`${{ github.repository }}`|Gitea 儲存庫 <擁有者>/<名稱>,預設是目前的儲存庫(github.repository)|
## 開發與發版
- CI(`ci.yaml`):用 [action-ci](https://gitea.jsc.idv.tw/actions/action-ci) 跑 shellcheck、Go 黑箱測試。
- CD(`cd.yaml`):「任何分支 → `main`」的 PR 合併時,用 [action-cd](https://gitea.jsc.idv.tw/actions/action-cd) 算下一個版本([next-version](https://gitea.jsc.idv.tw/actions/next-version),只遞增 patch、每位最大 9)並在 PR 來源最新提交上打標籤;只動文件、圖示、測試、`.gitea/`、`go.mod` 時不發版。直接推送 `main` 不發版。
- 呼叫端要把 Gitea 變數 `ACTION_DEPLOY_GO_VERSION` 改成新標籤才會採用。
- 圖示:`icon.svg`(儲存庫頭像用 `icon.png`)。