Update cleanup.yml

This commit is contained in:
Vaica committed 2026-06-27 19:49:46 +08:00
1 parent c05d991de6
commit 563bf2caef
1 file changed
+23 -5
+23 -5
View File
@@ -1,4 +1,4 @@
name: Cleanup Artifacts name: Cleanup Artifacts and Cache
on: on:
workflow_dispatch: workflow_dispatch:
@@ -12,16 +12,34 @@ jobs:
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
steps: steps:
- name: Delete all artifacts - name: Setup GitHub CLI
run: | run: |
# 安装 gh cli
gh extension install actions/gh-actions-cache || true gh extension install actions/gh-actions-cache || true
# 删除所有 artifacts - name: Delete all artifacts
echo "正在删除所有 artifacts..." run: |
echo "🗑️ 正在删除所有 artifacts..."
for artifact in $(gh api repos/${{ github.repository }}/actions/artifacts --paginate | jq -r '.artifacts[].id'); do for artifact in $(gh api repos/${{ github.repository }}/actions/artifacts --paginate | jq -r '.artifacts[].id'); do
echo "删除 artifact: $artifact" echo "删除 artifact: $artifact"
gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$artifact || true gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$artifact || true
done 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 "✅ 清理完成!" echo "✅ 清理完成!"