Skip to content

CleanUpCachePostPR #307

CleanUpCachePostPR

CleanUpCachePostPR #307

name: CleanUpCachePostPR
on:
workflow_run:
workflows: [PostPR]
types:
- completed
jobs:
CleanUpCcacheCachePostPR:
name: Clean Up Ccahe Cache Post PR
runs-on: ubuntu-24.04
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Clean up ccahe
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
gh run download ${{ github.event.workflow_run.id }} -n pr_number
pr_number=`cat pr_number.txt`
BRANCH=refs/pull/${pr_number}/merge
# Setting this to not fail the workflow while deleting cache keys.
set +e
keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH | cut -f 1)
for k in $keys
do
gh actions-cache delete $k -R $REPO -B $BRANCH --confirm
done