name: Cleanup Artifacts and Cache on: workflow_dispatch: jobs: cleanup: runs-on: ubuntu-latest permissions: actions: write contents: read env: GH_TOKEN: ${{ github.token }} steps: - name: Setup GitHub CLI run: | gh extension install actions/gh-actions-cache || true - 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 "✅ 清理完成!"