github.com/bodgit/sevenzip@v1.5.1/.github/workflows/cleanup.yml (about) 1 name: Clean up per-branch caches 2 3 on: 4 pull_request: 5 types: 6 - closed 7 workflow_dispatch: 8 9 permissions: 10 contents: read 11 12 jobs: 13 cleanup: 14 runs-on: ubuntu-latest 15 16 permissions: 17 actions: write 18 contents: read 19 20 steps: 21 - name: Checkout 22 uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 23 24 - name: Cleanup 25 run: | 26 gh extension install actions/gh-actions-cache 27 28 BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge 29 30 echo "Fetching list of cache keys" 31 keys=$(gh actions-cache list -R $GITHUB_REPOSITORY -B $BRANCH -L 100 | cut -f 1) 32 33 set +e 34 echo "Deleting caches..." 35 for key in $keys ; do 36 gh actions-cache delete $key -R $GITHUB_REPOSITORY -B $BRANCH --confirm 37 done 38 echo "Done" 39 env: 40 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}