-
Notifications
You must be signed in to change notification settings - Fork 9
36 lines (31 loc) · 1.05 KB
/
cache-cleanup.yml
File metadata and controls
36 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Cache Cleanup
on:
pull_request:
types: [closed]
jobs:
cleanup:
name: Clean PR Cache
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup PR caches
uses: actions/github-script@v7
with:
script: |
const ref = `refs/pull/${context.issue.number}/merge`;
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
ref: ref,
});
console.log(`Found ${caches.data.total_count} cache(s) for PR #${context.issue.number}`);
for (const cache of caches.data.actions_caches) {
console.log(`Deleting cache: ${cache.key} (${cache.size_in_bytes} bytes)`);
await github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
});
}
console.log('Cache cleanup complete');