Skip to content

Commit

Permalink
Improve example workflow to delete cache entries for closed PRs (#27618)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Edwards <[email protected]>
  • Loading branch information
TomAFrench and skedwards88 authored Oct 4, 2023
1 parent fa371f4 commit 3c7e291
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,11 @@ on:
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: {% data reusables.actions.action-checkout %}
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO={% raw %}${{ github.repository }}{% endraw %}
BRANCH="refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
Expand All @@ -368,6 +362,8 @@ jobs:
echo "Done"
env:
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
REPO: {% raw %}${{ github.repository }}{% endraw %}
BRANCH: refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge
```

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)."
Expand Down

0 comments on commit 3c7e291

Please sign in to comment.