Files
egui/.github/workflows/cache_cleanup.yml
Dylan M. Taylor 0965b68bdc ci: lock workflow actions through an actions.lock lockfile
Mutable action tags are a supply-chain risk: a moved tag runs different code
without a diff. Every workflow action is now pinned through
.github/workflows/actions.lock, and CI verifies the lockfile so an out-of-sync
or tampered one fails instead of running.
2026-11-12 10:04:46 -05:00

38 lines
1.1 KiB
YAML

# Delete the GitHub Actions caches of a pull request once it is closed.
#
# A repository can only hold 10 GB of caches, and the oldest ones are evicted when it is full.
# Without this the caches of merged pull requests would push out the `main` cache
# that every new pull request starts from.
name: Cache Cleanup
on:
pull_request:
types: [closed]
permissions:
actions: write
jobs:
cleanup:
name: Delete the caches of the closed PR
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
with:
egress-policy: audit
- name: Delete caches
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_REF: refs/pull/${{ github.event.pull_request.number }}/merge
BRANCH_REF: refs/heads/${{ github.event.pull_request.head.ref }}
run: |
for ref in "$PR_REF" "$BRANCH_REF"; do
echo "Deleting the caches of $ref"
gh cache list --ref "$ref" --limit 100 --json id --jq '.[].id' \
| xargs -r -I {} gh cache delete {}
done