Skip to content

Extend interface for extension dev and optimize In-Memory caching #20

Extend interface for extension dev and optimize In-Memory caching

Extend interface for extension dev and optimize In-Memory caching #20

Workflow file for this run

name: Cleanup
on:
delete:
workflow_dispatch:
pull_request:
types:
- closed
permissions:
actions: write
env:
BRANCH: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || format('refs/heads/{0}', github.event.ref) }}
jobs:
cleanup:
name: Cleanup at event ${{ github.event_name }} for branch ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || format('refs/heads/{0}', github.event.ref) }}
if: github.event.ref_type == 'branch' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
runs-on: ubuntu-24.04
steps:
- name: Branch Caches
run: |
echo "Fetching list of cache key"
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
deletedAny=0
for cacheKey in $cacheKeysForPR
do
deletedAny=1
gh cache delete $cacheKey
exitCode="$?"
if [ "$exitCode" -eq 0 ]; then
echo "deleted cache entry $cacheKey"
else
echo "failed to delete cache entry $cacheKey - exited with code $exitCode"
fi
done
if [ "$deletedAny" -eq 0 ]; then
echo "No cache entries found"
else
echo "Done"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}