From 5d34f2340df2414a455b4bc0cb3b6b6acaae1ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 19 May 2024 14:20:29 +0200 Subject: [PATCH] fuck_this_shit --- .github/workflows/cleanup_caches.yml | 25 +++++++++++++++++++++++++ .github/workflows/cleanup_caches_pr.yml | 22 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/cleanup_caches.yml create mode 100644 .github/workflows/cleanup_caches_pr.yml diff --git a/.github/workflows/cleanup_caches.yml b/.github/workflows/cleanup_caches.yml new file mode 100644 index 0000000000000..a76fdf6294846 --- /dev/null +++ b/.github/workflows/cleanup_caches.yml @@ -0,0 +1,25 @@ +name: Cleanup caches + +on: + workflow_run: + workflows: [build] + types: [completed] + +jobs: + cache: + runs-on: ubuntu-latest + steps: + - run: | + gh extension install actions/gh-actions-cache + keys=$(gh actions-cache list -L 100 -R ${{ github.repository }} -B $BRANCH --sort last-used --order desc | cut -f 1) + set +e + echo $BRANCH + echo $keys + for key in "${keys[@]:1}" + do + echo $key + gh actions-cache delete $key -R ${{ github.repository }} -B $BRANCH --confirm + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ github.event.workflow_run.head_branch }} diff --git a/.github/workflows/cleanup_caches_pr.yml b/.github/workflows/cleanup_caches_pr.yml new file mode 100644 index 0000000000000..1c630f3530ae3 --- /dev/null +++ b/.github/workflows/cleanup_caches_pr.yml @@ -0,0 +1,22 @@ +name: Cleanup caches PR + +on: + pull_request_target: + types: closed + +jobs: + pr_cache: + runs-on: ubuntu-latest + steps: + - run: | + gh extension install actions/gh-actions-cache + set +e + keys=$(gh actions-cache list -R ${{ github.repository }} -B $BRANCH | cut -f 1) + set +e + for key in $keys + do + gh actions-cache delete $key -R ${{ github.repository }} -B $BRANCH --confirm + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge