clear_gh_caches #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
schedule: | |
# At 00:00 on day-of-month 1 in every 2nd month. (i.e every 2 months) | |
- cron: '0 0 1 */2 *' | |
name: clear_gh_caches | |
jobs: | |
cleanup: | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cleanup | |
run: | | |
gh extension install actions/gh-actions-cache | |
REPO=${{ github.repository }} | |
echo "Fetching list of cache keys" | |
cacheKeys=$(gh actions-cache list -R $REPO | cut -f 1 ) | |
## Do not fail the workflow while deleting cache keys. | |
set +e | |
echo "Deleting caches..." | |
for cacheKey in $cacheKeys | |
do | |
gh actions-cache delete $cacheKey -R $REPO --confirm | |
done | |
echo "Done" |