Files
action-ci/README.md
T
bot 0289933c72
ci / test (pull_request) Successful in 8s
cd / tag (pull_request) Successful in 4s
調整:ci/cd 一致化(action-ci 自動偵測、action-cd)、版本計算抽到 next-version
2026-11-05 04:12:39 +00:00

36 lines
2.2 KiB
Markdown
Raw 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.
# action-ci
action repo 的共用 CI,自動偵測、不必設開關:
1. checkout(可關)
2. `shellcheck`(沒有符合的檔案就略過)
3. Go 腳本測試:有 `go.mod` 與 `test/` 才跑,在 `ci-env` 容器裡執行,`GO_VERSION=go.mod`(用 go.mod 的版本)
4. 建置映像檔:有 `Dockerfile` 才跑,映像檔標籤是 `action-test:<sha>`(唯一,不會撞到 runner 上的舊映像檔);有設 `docker_run_args` 時再實際執行一次並檢查輸出
```yaml
steps:
- uses: https://gitea.jsc.idv.tw/actions/action-ci@${{ vars.ACTION_ACTION_CI_VERSION }}
```
## 輸入
|名稱|預設|說明|
|---|---|---|
|`checkout`|`true`|先 checkout;`false`=呼叫端已經 checkout(例如要用 `uses: ./` 測自己)|
|`shellcheck_files`|`*.sh`|shellcheck 要檢查的檔案(空白分隔、可用萬用字元)|
|`go_test_command`|`go vet ./... && go test ./test/`|有 `go.mod` 與 `test/` 時執行的指令|
|`docker_run_args`||建置後實際執行容器的 entrypoint 參數(每行一個),空=只建置不執行|
|`docker_run_options`||執行容器的 `docker create` 選項(每行一個,例如 `--env=INPUT_TASK=x`)|
|`docker_run_expect`||容器輸出必須包含的字串,空=只檢查結束碼|
不要對 Docker action 用 `uses: ./` 自測:這台 runner 會依名稱重用舊映像檔,可能跑到別的專案的映像檔。
內部用的 `shellcheck`、`ci-env` 版本取自呼叫端 repo 的 Gitea 變數 `ACTION_SHELLCHECK_VERSION`、`ACTION_CI_ENV_VERSION`(不寫死在 `action.yml`),所以呼叫端要先設好這兩個變數。
## 開發與發版
- CI(`ci.yaml`):用自己(`uses: ./`)檢查 shellcheck。
- 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_ACTION_CI_VERSION` 改成新標籤才會採用。
- 圖示:`icon.svg`(儲存庫頭像用 `icon.png`)。