11name : ' Cleanup'
22
33on :
4+ push :
5+ branches :
6+ - ci/**
47 schedule :
58 - cron : ' 0 0 * * 0'
69 workflow_dispatch :
@@ -11,33 +14,35 @@ permissions:
1114
1215jobs :
1316 garbage-collector :
14- name : ' Cache & Artifacts '
17+ name : ' Purge Storage '
1518 runs-on : ubuntu-latest
1619 steps :
17- - name : ' Purge All Caches'
20+ - name : Checkout
21+ uses : actions/checkout@v4
22+
23+ - name : ' Clean Actions Cache'
1824 shell : bash
1925 run : |
20- gh extension install actions/gh-actions-cache
21- echo "::group::Cleaning Caches"
22- # Удаляем все кэши. Если нужно оставить main, добавь: -B main
23- gh actions-cache delete --all --confirm
26+ echo "::group::Deleting Caches"
27+ gh cache delete --all --succeed-on-no-caches || echo "Caches already empty or cleared"
2428 echo "::endgroup::"
2529 env :
2630 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2731
28- - name : ' Purge Old Artifacts'
32+ - name : ' Clean Old Artifacts'
2933 shell : bash
3034 run : |
31- echo "::group::Cleaning Artifacts"
32- gh run allocation-status --repo ${{ github.repository }}
33-
34- artifacts=$(gh api repos/${{ github.repository }}/actions/artifacts --paginate -q '.artifacts[].id')
35-
36- for artifact_id in $artifacts; do
37- gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$artifact_id
38- done
35+ echo "::group::Deleting Artifacts"
36+ artifacts=$(gh api repos/${{ github.repository }}/actions/artifacts --paginate -q '.artifacts[].id' || echo "")
3937
40- echo "All artifacts deleted."
38+ if [ -n "$artifacts" ]; then
39+ for id in $artifacts; do
40+ gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$id || true
41+ done
42+ echo "Artifacts cleared."
43+ else
44+ echo "No artifacts found."
45+ fi
4146 echo "::endgroup::"
4247 env :
4348 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments