Skip to content

feat: versioned (CAS) user writes in basic lock script #478

feat: versioned (CAS) user writes in basic lock script

feat: versioned (CAS) user writes in basic lock script #478

name: "Ops: Cache Cleanup"
on:
pull_request:
types:
- closed
workflow_dispatch:
permissions:
contents: read
jobs:
cleanup:
permissions:
actions: write # to delete PR caches via gh cache delete
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- name: Cleanup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
BRANCH="refs/pull/${PR_NUMBER}/merge"
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh cache list -R "$REPO" --ref "$BRANCH" | cut -f 1)
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh cache delete "$cacheKey" -R "$REPO"
done
echo "Done"