forked from OpenFUSIONToolkit/OpenFUSIONToolkit
-
Notifications
You must be signed in to change notification settings - Fork 3
46 lines (41 loc) · 1.43 KB
/
Copy pathprune_cache.yaml
File metadata and controls
46 lines (41 loc) · 1.43 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
37
38
39
40
41
42
43
44
45
46
name: Cleanup build caches
on:
pull_request:
types:
- closed
workflow_dispatch:
inputs:
pr_number:
description: 'Pull request number to clean up caches for'
required: true
type: string
jobs:
cleanup:
if: github.repository == 'OpenFUSIONToolkit/OpenFUSIONToolkit'
runs-on: ubuntu-latest
permissions:
# `actions:write` permission is required to delete caches
# See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
actions: write
contents: read
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Cleanup cache
run: |
gh extension install actions/gh-actions-cache
BRANCH="refs/pull/${PR_NUMBER}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }}