| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- name: Cache Cleanup
- description: Deletes cache releases for the specified cache buckets.
- inputs:
- cache_bucket:
- description: Single release tag name to delete (use cache_buckets for multiple)
- required: false
- default: 'general-cache'
- cache_buckets:
- description: Multiline list of release tag names to delete
- required: false
- default: ""
- github_token:
- description: GitHub token for release deletion authentication
- required: true
- confirm:
- description: Must be true to actually delete releases
- required: false
- default: false
- runs:
- using: "composite"
- steps:
- - name: Delete Cache Releases
- shell: bash
- env:
- GITHUB_TOKEN: ${{ inputs.github_token }}
- TARGET_REPO: "${{ github.repository }}"
- run: |
- set -euo pipefail
- if [ "${{ inputs.confirm }}" != "true" ]; then
- echo "Cache cleanup is disabled. Re-run with confirm=true to delete releases."
- exit 0
- fi
- BUCKETS_INPUT="${{ inputs.cache_buckets }}"
- if [ -z "$BUCKETS_INPUT" ]; then
- BUCKETS_INPUT="${{ inputs.cache_bucket }}"
- fi
- IFS=$'\n' read -rd '' -a BUCKETS_ARRAY <<<"$BUCKETS_INPUT" || true
- for TAG_NAME in "${BUCKETS_ARRAY[@]}"; do
- [ -z "$TAG_NAME" ] && continue
- echo "Checking cache release: $TAG_NAME"
- if gh release view "$TAG_NAME" --repo "$TARGET_REPO" >/dev/null 2>&1; then
- echo "Deleting cache release and tag: $TAG_NAME"
- gh release delete "$TAG_NAME" --cleanup-tag -y --repo "$TARGET_REPO"
- else
- echo "No cache release found for $TAG_NAME"
- fi
- done
|