Skip to content

Update delete_caches.yaml #7

Update delete_caches.yaml

Update delete_caches.yaml #7

name: cleanup caches by a branch
on:
push:
branches: '**'
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache keys"
cacheKeys=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
echo "Cache keys-->: $cacheKeys"
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeys
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.PAT }}
REPO: ${{ github.repository }}
BRANCH: main