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

34 lines
1.9 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.
# ci-run
組合 `ci-cache` 與 `ci-env`,跑一個 CI 工作:checkout → 還原快取 → 在容器裡執行指令。快取 key 由 `cache_files` 的內容雜湊決定(不用在每個工作重複 `hashFiles(...)`)。
```yaml
steps:
- uses: https://gitea.jsc.idv.tw/actions/ci-run@${{ vars.ACTION_CI_RUN_VERSION }}
with:
cache_files: go.sum web/package-lock.json
command: bash scripts/ci.sh vet
```
## 輸入
|名稱|必填|預設|說明|
|---|---|---|---|
|`command`|是||要在 `ci-env` 容器裡執行的 shell 指令|
|`cache_files`||`go.sum`|決定快取 key 的檔案(空白分隔),內容變了才換快取;不存在的檔案略過|
|`cache_key`|||直接指定快取 key,有值就不用 `cache_files` 算|
|`cache_prefix`||`ci-home-`|快取 key 的前綴,找不到完全相同的 key 時也用它還原最近的快取|
|`checkout`||`true`|先 checkout;`false`=呼叫端已經 checkout|
|`name`||`ci`|執行指令的步驟名稱|
## 內部引用的版本
`ci-cache`、`ci-env` 的版本取自呼叫端 repo 的 Gitea 變數 `ACTION_CI_CACHE_VERSION`、`ACTION_CI_ENV_VERSION`,不寫死在 `action.yml`,所以呼叫端要先設好這兩個變數。需要工具鏈時,呼叫端的工作流要有 `env: GO_VERSION`、`NODE_VERSION`。
## 開發與發版
- CI(`ci.yaml`):用 [action-ci](https://gitea.jsc.idv.tw/actions/action-ci),並用 `uses: ./` 實際執行一次。
- 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_CI_RUN_VERSION` 改成新標籤才會採用。
- 圖示:`icon.svg`(儲存庫頭像用 `icon.png`)。