Skip to content

Commit 56621e4

Browse files
committed
chore(template): sync with dailydevops/dotnet-template [skip ci]
1 parent e144455 commit 56621e4

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Delete Cache after PR merge
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
12+
jobs:
13+
cleanup:
14+
name: Clear cache
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Cleanup
24+
run: |
25+
gh extension install actions/gh-actions-cache
26+
27+
REPO=${{ github.repository }}
28+
29+
# get the branch
30+
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
31+
32+
# fetch list of cache key
33+
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
34+
35+
# set this to not fail the workflow while deleting cache keys
36+
set +e
37+
38+
# delete cache key
39+
for cacheKey in $cacheKeysForPR
40+
do
41+
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
42+
done
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-nuget.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
permissions:
1010
actions: read
1111
contents: write
12+
pull-requests: write
1213

1314
concurrency:
1415
group: publish-nuget

0 commit comments

Comments
 (0)