commit 74fcb0216bfff569b98a87d7515847e67164ba34 Author: bot Date: Thu Nov 5 02:54:24 2026 +0000 初始版本:從 feather-vault 搬出 diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..b878276 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,18 @@ +name: ci +on: + push: + branches: [main] + pull_request: +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true +jobs: + test: + runs-on: docker-ubuntu + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + cache_key: ci-run-selftest-${{ github.sha }} + cache_restore_keys: ci-run-selftest- + command: echo ok diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca6f005 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# ci-run + +組合 `ci-cache` 與 `ci-env`:先還原快取,再在容器裡執行指令。 + +## 用法 + +版本由呼叫端的 Gitea Actions 變數決定(例如 `vars.ACTION_CI_RUN_VERSION`),不要用分支名稱:runner 依 ref 重用舊映像檔,改了腳本不會生效,所以每次改動都發新標籤。 + +```yaml +- uses: https://gitea.jsc.idv.tw/actions/ci-run@${{ vars.ACTION_CI_RUN_VERSION }} + with: + command: ... + cache_key: ... +``` + +## 輸入 + +|名稱|必填|預設|說明| +|---|---|---|---| +|`command`|是||要在 ci-env 容器裡執行的 shell 指令| +|`cache_key`|是||快取 key,例如 ci-home-${{ hashFiles('go.sum', 'web/package-lock.json') }}| +|`cache_restore_keys`|||找不到完全相同的 key 時,依序嘗試的前綴(每行一個)| +|`name`||`ci`|執行指令的步驟名稱| + +## 開發 + +`ci.yaml` 跑 ,並用 `uses: ./` 實際執行一次。 + +圖示:`icon.svg`(Gitea 儲存庫頭像用 `icon.png`)。 diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..355a09b --- /dev/null +++ b/action.yml @@ -0,0 +1,26 @@ +name: ci-run +description: "跑一個 CI 工作:還原快取(ci-cache)→ 在 ci-env 容器裡執行指令。要在 checkout 之後使用,需要工具鏈時呼叫的工作流要有 env: GO_VERSION、NODE_VERSION" +inputs: + command: + description: "要在 ci-env 容器裡執行的 shell 指令" + required: true + cache_key: + description: "快取 key,例如 ci-home-${{ hashFiles('go.sum', 'web/package-lock.json') }}" + required: true + cache_restore_keys: + description: "找不到完全相同的 key 時,依序嘗試的前綴(每行一個)" + default: "" + name: + description: "執行指令的步驟名稱" + default: ci +runs: + using: composite + steps: + - uses: https://gitea.jsc.idv.tw/actions/ci-cache@v0.0.1 + with: + key: ${{ inputs.cache_key }} + restore_keys: ${{ inputs.cache_restore_keys }} + - name: ${{ inputs.name }} + uses: https://gitea.jsc.idv.tw/actions/ci-env@v0.0.1 + with: + command: ${{ inputs.command }} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..d02b81c Binary files /dev/null and b/icon.png differ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..b2c7a96 --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file