Skip to content

Commit 52db0b5

Browse files
committed
GitHub: Delete previous cache before saving new
1 parent f229c6b commit 52db0b5

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/openwrt-build.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
name: Build OpenWRT ${{ matrix.version }} for ${{ matrix.lunch }}
1616
runs-on: ubuntu-latest
1717

18+
env:
19+
cache-key: ${{ runner.os }}-${{ matrix.version }}-${{ matrix.lunch }}
20+
1821
strategy:
1922
fail-fast: false
2023
matrix:
@@ -31,7 +34,7 @@ jobs:
3134
uses: actions/cache/restore@v3
3235
with:
3336
path: openwrt-builder
34-
key: ${{ runner.os }}-${{ matrix.version }}-${{ matrix.lunch }}
37+
key: ${{ env.cache-key }}
3538

3639
- name: Check if the OpenWRT builder exists
3740
id: check
@@ -94,8 +97,17 @@ jobs:
9497
clean
9598
cd ..
9699
100+
- name: Delete previous cache before saving new
101+
if: ${{ steps.restore-cache.outputs.cache-hit }}
102+
continue-on-error: true
103+
run: |
104+
gh extension install actions/gh-actions-cache
105+
gh-actions-cache delete "${{ env.cache-key }}" --confirm
106+
env:
107+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
97109
- name: Save OpenWRT builder cache
98110
uses: actions/cache/save@v3
99111
with:
100112
path: openwrt-builder
101-
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
113+
key: ${{ env.cache-key }}

0 commit comments

Comments
 (0)