Files
action-cd/README.md
T
2026-11-05 04:44:30 +00:00

51 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.
# action-cd
action repo 的共用 CD:
1. checkout PR 來源分支的最新提交(`pull_request.head.sha`),完整歷史
2. 用 [next-version](https://gitea.jsc.idv.tw/actions/next-version) 算下一個版本(只看 git 標籤)
3. 沒有跳過就在該提交上打標籤並推送;只動文件、圖示、測試、`.gitea/`、`go.mod` 時跳過
典型的 `cd.yaml`(觸發條件由呼叫端決定,這裡是「任何分支 → main」的 PR 合併時):
```yaml
on:
pull_request:
types: [closed]
branches: [main]
concurrency:
group: cd
cancel-in-progress: false
jobs:
tag:
if: ${{ github.event.pull_request.merged == true }}
runs-on: docker-ubuntu
steps:
- uses: https://gitea.jsc.idv.tw/actions/action-cd@${{ vars.ACTION_ACTION_CD_VERSION }}
with:
token: ${{ secrets.TOKEN || github.token }}
```
## 輸入
|名稱|預設|說明|
|---|---|---|
|`token`||推送標籤用的權杖(需要 `write:repository`);空=用內建 `github.token`|
|`docs_pattern`|`^\.gitea/\|^icon\.\|^test/\|^go\.mod$\|\.md$`|只動這些檔案就不發版的 egrep 規則|
## 輸出
|名稱|說明|
|---|---|
|`version`|這次發的版本(跳過時是下一版的預覽,沒有實際推送)|
|`skip`|`true`=只動文件等檔案,沒有發版|
內部用的版本取自呼叫端 repo 的 Gitea 變數 `ACTION_CHECKOUT_VERSION`、`ACTION_NEXT_VERSION_VERSION`,所以呼叫端要先設好。呼叫端用標籤引用 action(版本取自 Gitea 變數),發版後要把 `ACTION_<名稱>_VERSION` 改成新標籤才會採用。
## 開發與發版
- CI(`ci.yaml`):用 [action-ci](https://gitea.jsc.idv.tw/actions/action-ci)(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_CD_VERSION` 改成新標籤才會採用。
- 圖示:`icon.svg`(儲存庫頭像用 `icon.png`)。