Skip to content

Extension shortcode support (Phase 3) #10

Extension shortcode support (Phase 3)

Extension shortcode support (Phase 3) #10

Workflow file for this run

name: Cleanup caches on closed pull requests
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
if: github.repository == 'quarto-dev/q2'
permissions:
actions: write
steps:
- name: Cleanup
run: |
echo "::group::Fetching cache list for PR #${{ github.event.pull_request.number }}"
echo "Branch ref: $BRANCH"
# Get up to 1000 caches for this PR ref
cacheList=$(gh cache list --ref $BRANCH --limit 1000 --json id,key,sizeInBytes)
cacheCount=$(echo "$cacheList" | jq '. | length')
echo "Found $cacheCount cache(s) for this PR"
if [ "$cacheCount" -gt 0 ]; then
echo "Cache details:"
echo "$cacheList" | jq -r '.[] | " - ID: \(.id) | Key: \(.key) | Size: \(.sizeInBytes | tonumber / 1024 / 1024 | floor)MB"'
fi
echo "::endgroup::"
if [ "$cacheCount" -eq 0 ]; then
echo "No caches to delete"
exit 0
fi
# Extract just the IDs for deletion
cacheKeysForPR=$(echo "$cacheList" | jq -r '.[].id')
echo "::group::Deleting caches"
deleted=0
failed=0
for cacheKey in $cacheKeysForPR
do
echo "Deleting cache ID: $cacheKey"
if gh cache delete $cacheKey; then
echo " ✓ Successfully deleted cache $cacheKey"
deleted=$((deleted+1))
else
echo " ✗ Failed to delete cache $cacheKey"
failed=$((failed+1))
fi
done
echo "::endgroup::"
echo "::notice::Cache cleanup complete: $deleted deleted, $failed failed out of $cacheCount total"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge