From cc80095e8ee0f6768cf9e6db52600b40a91bd778 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 12 Feb 2024 17:24:17 +0100 Subject: [PATCH] Fix cache cleanup script (now tested to work) (#999) * Try fix suggested in https://github.com/github/docs/pull/31322 * Add `actions: write` permission --- .github/workflows/clean-cache-post-merge.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clean-cache-post-merge.yml b/.github/workflows/clean-cache-post-merge.yml index 6a7bbdce1e..ad77ebf919 100644 --- a/.github/workflows/clean-cache-post-merge.yml +++ b/.github/workflows/clean-cache-post-merge.yml @@ -2,13 +2,16 @@ # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy name: cleanup caches by a branch on: - pull_request: + pull_request_target: types: - closed + workflow_dispatch: jobs: cleanup: runs-on: ubuntu-latest + permissions: + actions: write steps: - name: Cleanup run: | @@ -22,10 +25,11 @@ jobs: echo "Deleting caches..." for cacheKey in $cacheKeysForPR do + echo "Deleting $cacheKey" gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm done echo "Done" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} - BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge + BRANCH: ${{ github.ref_name }}