commit 03f90ca0d562edb133fb294e7fcd71821b7c1854 Author: bot Date: Thu Nov 5 02:54:20 2026 +0000 初始版本:從 feather-vault 搬出 diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..17017fa --- /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: + key: ci-cache-selftest-${{ github.sha }} + restore_keys: ci-cache-selftest- + path: .ci-home diff --git a/README.md b/README.md new file mode 100644 index 0000000..a822286 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# ci-cache + +包一層 `actions/cache`,預設快取 workspace 的 `.ci-home`(Go 模組與建置快取、npm、工具鏈、rod 下載的 Chromium)。key 由呼叫端用 `hashFiles` 算好傳入。 + +## 用法 + +版本由呼叫端的 Gitea Actions 變數決定(例如 `vars.ACTION_CI_CACHE_VERSION`),不要用分支名稱:runner 依 ref 重用舊映像檔,改了腳本不會生效,所以每次改動都發新標籤。 + +```yaml +- uses: https://gitea.jsc.idv.tw/actions/ci-cache@${{ vars.ACTION_CI_CACHE_VERSION }} + with: + key: ... +``` + +## 輸入 + +|名稱|必填|預設|說明| +|---|---|---|---| +|`key`|是||快取 key,例如 ci-home-${{ hashFiles('go.sum', 'web/package-lock.json') }}| +|`restore_keys`|||找不到完全相同的 key 時,依序嘗試的前綴(每行一個),例如 ci-home-| +|`path`||`.ci-home`|要快取的路徑| + +## 開發 + +`ci.yaml` 跑 ,並用 `uses: ./` 實際執行一次。 + +圖示:`icon.svg`(Gitea 儲存庫頭像用 `icon.png`)。 diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..e603ac9 --- /dev/null +++ b/action.yml @@ -0,0 +1,20 @@ +name: ci-cache +description: "還原與儲存 CI 的快取目錄(預設 workspace 的 .ci-home:Go 模組與建置快取、npm、工具鏈、rod 下載的 Chromium)。包一層 actions/cache,要在 checkout 之後使用;key 由呼叫端用 hashFiles 算好傳入" +inputs: + key: + description: "快取 key,例如 ci-home-${{ hashFiles('go.sum', 'web/package-lock.json') }}" + required: true + restore_keys: + description: "找不到完全相同的 key 時,依序嘗試的前綴(每行一個),例如 ci-home-" + default: "" + path: + description: "要快取的路徑" + default: .ci-home +runs: + using: composite + steps: + - uses: actions/cache@v4 + with: + path: ${{ inputs.path }} + key: ${{ inputs.key }} + restore-keys: ${{ inputs.restore_keys }} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..2a7ffd5 Binary files /dev/null and b/icon.png differ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..3ed8637 --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file