Skip to content

Commit aabba2f

Browse files
committed
Delete stored cache on build:clean
1 parent 333809c commit aabba2f

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/pr.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ jobs:
3030
build_and_cache_dependencies_if_needed:
3131
needs: generate_cache_key
3232
runs-on: ubuntu-latest
33-
container: mcr.microsoft.com/playwright:v1.57.0-jammy
33+
container: mcr.microsoft.com/playwright:v1.57.0-jammy
34+
permissions:
35+
actions: write
3436
steps:
3537
- uses: actions/checkout@v4
3638
- uses: actions/setup-node@v4
@@ -66,6 +68,20 @@ jobs:
6668
} catch (error) {
6769
core.warning(`Failed to remove ' + labelToRemove + ' label: ${error.message}`);
6870
}
71+
- name: Delete existing cache (to allow re-save on build:clean)
72+
if: steps.node_deps_restore_cache.outputs.cache-hit == 'true' && contains(github.event.pull_request.labels.*.name, 'build:clean')
73+
uses: actions/github-script@v6
74+
with:
75+
script: |
76+
try {
77+
await github.rest.actions.deleteActionsCacheByKey({
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
key: '${{ needs.generate_cache_key.outputs.cache_key }}'
81+
});
82+
} catch (error) {
83+
core.warning(`Failed to delete cache: ${error.message}`);
84+
}
6985
- uses: actions/cache/save@v4
7086
id: node_deps_save_cache
7187
if: steps.node_deps_restore_cache.outputs.cache-hit != 'true' || contains(github.event.pull_request.labels.*.name, 'build:clean')

0 commit comments

Comments
 (0)