Update doc for linter debug locally #121
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: | |
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries | |
name: Cleanup caches by a branch | |
on: # yamllint disable-line rule:truthy | |
pull_request: | |
types: | |
- closed | |
jobs: | |
cleanup: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
contents: write | |
steps: | |
- name: Cleanup | |
run: | | |
{ | |
echo "# Cache Cleanup Summary" | |
echo "" | |
echo "**PR Number:** #${{ github.event.pull_request.number }}" | |
echo "**Branch:** \`$BRANCH\`" | |
echo "" | |
} >> "$GITHUB_STEP_SUMMARY" | |
echo "[DEBUG] Fetching cache list..." | |
# Get full cache details | |
CACHE_LIST=$(gh cache list --ref "$BRANCH" --limit 100 --json key,sizeInBytes,id) | |
if [ -z "$CACHE_LIST" ] || [ "$CACHE_LIST" = "[]" ]; then | |
echo "[DEBUG] No caches found" | |
echo "No caches found for this PR" >> "$GITHUB_STEP_SUMMARY" | |
exit 0 | |
fi | |
{ | |
echo "| Cache ID | Cache Key | Size |" | |
echo "|----------|-----------|------|" | |
} >> "$GITHUB_STEP_SUMMARY" | |
# Extract IDs and process deletions | |
echo "$CACHE_LIST" | jq -r '.[] | [.id, .key, .sizeInBytes] | @tsv' | while IFS=$'\t' read -r id key size; do | |
# Convert size to human readable format | |
if [ "$size" -ge 1048576 ]; then | |
readable_size=$(echo "scale=2; $size/1048576" | bc 2>/dev/null || echo "$size")"MB" | |
else | |
readable_size=$(echo "scale=2; $size/1024" | bc 2>/dev/null || echo "$size")"KB" | |
fi | |
echo "[DELETE] Processing cache ID: $id" | |
gh cache delete "$id" | |
echo "[INFO] Processed cache $id" | |
# Add row to summary table | |
echo "| \`$id\` | \`$key\` | $readable_size |" >> "$GITHUB_STEP_SUMMARY" | |
done | |
{ | |
echo "" | |
echo "Cleanup completed at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" | |
} >> "$GITHUB_STEP_SUMMARY" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ github.repository }} | |
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge |