Skip to content

Improve example workflow to delete cache entries for closed PRs #27618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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