diff --git a/.github/workflows/clear-pr-caches.yml b/.github/workflows/clear-pr-caches.yml index 049af6226ba..c0f1f5d0d4a 100644 --- a/.github/workflows/clear-pr-caches.yml +++ b/.github/workflows/clear-pr-caches.yml @@ -1,7 +1,7 @@ name: clear-pr-caches on: - pull_request: + pull_request_target: types: [ closed ] permissions: @@ -9,9 +9,16 @@ permissions: jobs: clear-caches: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: clear-caches - uses: theAngularGuy/clear-cache-of-pull-request@60c83956d63c7b3745d6cde10d711aa0e50c2501 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge + run: | + cacheKeysForPR=$(gh cache list --ref "$BRANCH" --limit 100 --json id --jq '.[].id') + set +e + for cacheKey in $cacheKeysForPR; do + gh cache delete "$cacheKey" + done