From 1f9b0bfc17500926993aec8c695167b9376d23a8 Mon Sep 17 00:00:00 2001 From: baerwang <52104949+baerwang@users.noreply.github.com> Date: Fri, 22 Dec 2023 07:48:19 +0800 Subject: [PATCH] ci: auto delete cache (#2232) --- .github/workflows/clean-cache.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/clean-cache.yml diff --git a/.github/workflows/clean-cache.yml b/.github/workflows/clean-cache.yml new file mode 100644 index 0000000000..c26458c499 --- /dev/null +++ b/.github/workflows/clean-cache.yml @@ -0,0 +1,22 @@ +name: Cleanup Caches By a Branch +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + for cacheKey in $(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm & + done + wait + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge \ No newline at end of file