clear-cache.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. name: Clear Cache Releases
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. confirm:
  6. description: 'Type DELETE to confirm wiping all General Cache releases'
  7. type: string
  8. default: ''
  9. required: true
  10. permissions:
  11. contents: write
  12. jobs:
  13. clear-cache:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Verify confirmation
  17. run: |
  18. if [ "${{ inputs.confirm }}" != "DELETE" ]; then
  19. echo "Refusing: confirm input must be DELETE (got '${{ inputs.confirm }}')." >&2
  20. exit 1
  21. fi
  22. - name: Delete all General Cache releases
  23. env:
  24. GH_TOKEN: ${{ github.token }}
  25. run: |
  26. set -euo pipefail
  27. TAGS=$(gh release list --limit 1000 --json tagName,name --jq -r '.[] | select(.name == "General Cache") | .tagName')
  28. if [ -z "$TAGS" ]; then
  29. echo "No General Cache releases found. Nothing to do."
  30. exit 0
  31. fi
  32. echo "$TAGS" | while read -r tag; do
  33. [ -n "$tag" ] || continue
  34. echo "Deleting release + tag: $tag"
  35. gh release delete "$tag" --cleanup-tag -y || echo "WARNING: failed to delete $tag (continuing)"
  36. done
  37. echo "Done."