Skip to content

Add link_identity_short workaround #483

Add link_identity_short workaround

Add link_identity_short workaround #483

name: Cleanup caches after PR closed
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH=${{ github.head_ref }}
if [ -z "$BRANCH" ]; then
echo "Branch is empty, quit now"
exit 0
fi
# BRANCH doesn't necessarily have a cache
cacheKeysForPR=$(gh actions-cache list -R $REPO | cut -f 1 | grep "$BRANCH" || true)
echo "Deleting caches after PR closed for branch $BRANCH ..."
for cacheKey in $cacheKeysForPR
do
echo " Delete cache: $cacheKey"
gh actions-cache delete $cacheKey -R $REPO --confirm || true
done
echo "Done"
env:
GH_TOKEN: ${{ github.token }}