Skip to content

Commit 1d59372

Browse files
authored
⬆️🔨 upgrade cache cleanup script (#8390)
1 parent af7ba09 commit 1d59372

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

.github/workflows/cleanup-caches-by-branches.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ on:
88
jobs:
99
cleanup:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
actions: write
1113
steps:
1214
- name: Cleanup
1315
run: |
14-
gh extension install actions/gh-actions-cache
15-
16-
echo "Fetching list of cache key"
17-
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
16+
echo "Fetching list of cache keys"
17+
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
1818
1919
## Setting this to not fail the workflow while deleting cache keys.
2020
set +e
2121
echo "Deleting caches..."
2222
for cacheKey in $cacheKeysForPR
2323
do
24-
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
24+
gh cache delete $cacheKey
2525
done
2626
echo "Done"
2727
env:
28-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
REPO: ${{ github.repository }}
28+
GH_TOKEN: ${{ github.token }}
29+
GH_REPO: ${{ github.repository }}
3030
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

0 commit comments

Comments
 (0)