Skip to content

Commit 3c7e291

Browse files
TomAFrenchSarah Edwards
andauthored
Improve example workflow to delete cache entries for closed PRs (#27618)
Co-authored-by: Sarah Edwards <[email protected]>
1 parent fa371f4 commit 3c7e291

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

content/actions/using-workflows/caching-dependencies-to-speed-up-workflows.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,11 @@ on:
344344
jobs:
345345
cleanup:
346346
runs-on: ubuntu-latest
347-
steps:
348-
- name: Check out code
349-
uses: {% data reusables.actions.action-checkout %}
350-
347+
steps:
351348
- name: Cleanup
352349
run: |
353350
gh extension install actions/gh-actions-cache
354351
355-
REPO={% raw %}${{ github.repository }}{% endraw %}
356-
BRANCH="refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge"
357-
358352
echo "Fetching list of cache key"
359353
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
360354
@@ -368,6 +362,8 @@ jobs:
368362
echo "Done"
369363
env:
370364
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
365+
REPO: {% raw %}${{ github.repository }}{% endraw %}
366+
BRANCH: refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge
371367
```
372368

373369
Alternatively, you can use the API to automatically list or delete all caches on your own cadence. For more information, see "[AUTOTITLE](/rest/actions/cache#about-the-cache-in-github-actions)."

0 commit comments

Comments
 (0)