Skip to content

Commit ec184db

Browse files
Improve CleanupCaches workflow: use native gh cache commands, remove unnecessary checkout, add permissions block
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
1 parent 53da8f3 commit ec184db

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

.github/workflows/CleanupCaches.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,27 @@ on:
44
types:
55
- closed
66

7+
permissions:
8+
actions: write
9+
710
jobs:
811
cleanup:
912
runs-on: ubuntu-latest
1013
steps:
11-
- name: Check out code
12-
uses: actions/checkout@v6
13-
1414
- name: Cleanup
1515
run: |
16-
gh extension install actions/gh-actions-cache
17-
1816
REPO=${{ github.repository }}
1917
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
2018
21-
echo "Fetching list of cache key"
22-
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
19+
echo "Fetching list of cache keys"
20+
cacheKeysForPR=$(gh cache list -R $REPO --ref $BRANCH | cut -f 1)
2321
24-
## Setting this to not fail the workflow while deleting cache keys.
22+
## Setting this to not fail the workflow while deleting cache keys.
2523
set +e
2624
echo "Deleting caches..."
2725
for cacheKey in $cacheKeysForPR
2826
do
29-
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
27+
gh cache delete $cacheKey -R $REPO
3028
done
3129
echo "Done"
3230
env:

0 commit comments

Comments
 (0)