# CLEANUP OLD NUGET 清理 Gitea NuGet 套件舊版本的 Docker Action。 ## 功能 - 依序嘗試取得 Gitea API token。 - 預設每個套件保留最新 `2` 個版本。 - 預設為 `dry_run=true`,只列出候選,不會真的刪除。 - 輸出可搜尋的 log,包含 API status、request id 與 summary。 ## Token 來源順序 Action 會依序嘗試以下來源: 1. `inputs.RUNNER_TOKEN` 2. `secrets.GITEA_TOKEN` 3. `secrets.RUNNER_TOKEN` 若三者都沒有值,Action 會以非零 exit code 結束。 ## Inputs | 名稱 | 類型 | 預設值 | 說明 | | --- | --- | --- | --- | | `RUNNER_TOKEN` | string | - | Gitea API token,優先順序最高 | | `KEEP_VERSIONS` | integer string | `2` | 每個套件要保留的最新版本數,必須是整數且 `>= 0` | | `DRY_RUN` | boolean string | `true` | `true` 只列出候選,`false` 才會呼叫 DELETE API | ## Log 行為 執行時會輸出這類資訊: - `Trying token from ...` - `Using token from ...` - `keep_versions=...` - `dry_run=...` - `GET /api/v1/... -> 200 OK` - `Candidate to delete: ...` - `[DRY-RUN] Would delete ...` - `Deleted package ... -> 204 No Content` - `Summary: packages=... versions=... kept=... candidates=... deleted=... skipped=... errors=...` ## Workflow 範例 ### Dry-run ```yaml jobs: cleanup: runs-on: ubuntu steps: - uses: ./ with: RUNNER_TOKEN: ${{ secrets.GITEA_TOKEN }} KEEP_VERSIONS: 2 DRY_RUN: true ``` ### 實際刪除 ```yaml jobs: cleanup: runs-on: ubuntu steps: - uses: ./ with: RUNNER_TOKEN: ${{ secrets.GITEA_TOKEN }} KEEP_VERSIONS: 2 DRY_RUN: false ``` ## 測試 - Shell 測試: [`tests/entrypoint.sh`](tests/entrypoint.sh) - Gitea workflow: [`.gitea/workflows/ci.yaml`](.gitea/workflows/ci.yaml) ## 相關檔案 - Action 定義: [`action.yaml`](action.yaml) - 執行腳本: [`entrypoint.sh`](entrypoint.sh)