From 045c2f211e2d40576b25986faa53a3987d3aa9d4 Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Sat, 27 Jun 2026 19:49:46 +0800 Subject: [PATCH] Update cleanup.yml --- .github/workflows/cleanup.yml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index bd08d9ac..366370c7 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -1,4 +1,4 @@ -name: Cleanup Artifacts +name: Cleanup Artifacts and Cache on: workflow_dispatch: @@ -12,16 +12,34 @@ jobs: env: GH_TOKEN: ${{ github.token }} steps: - - name: Delete all artifacts + - name: Setup GitHub CLI run: | - # 安装 gh cli gh extension install actions/gh-actions-cache || true - # 删除所有 artifacts - echo "正在删除所有 artifacts..." + - name: Delete all artifacts + run: | + echo "🗑️ 正在删除所有 artifacts..." for artifact in $(gh api repos/${{ github.repository }}/actions/artifacts --paginate | jq -r '.artifacts[].id'); do echo "删除 artifact: $artifact" gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$artifact || true done + echo "✅ Artifacts 清理完成!" + - name: Delete all caches + run: | + echo "🗑️ 正在删除所有 caches..." + for cache in $(gh api repos/${{ github.repository }}/actions/caches --paginate | jq -r '.actions_caches[].id'); do + echo "删除 cache: $cache" + gh api -X DELETE repos/${{ github.repository }}/actions/caches/$cache || true + done + echo "✅ Caches 清理完成!" + + - name: Verify cleanup + run: | + echo "📊 当前存储状态:" + echo "Artifacts:" + gh api repos/${{ github.repository }}/actions/artifacts --paginate | jq -r '.artifacts | length' | xargs -I {} echo " - {} 个 artifacts" + echo "Caches:" + gh api repos/${{ github.repository }}/actions/caches --paginate | jq -r '.actions_caches | length' | xargs -I {} echo " - {} 个 caches" + echo "" echo "✅ 清理完成!"