Cache invalidation #7
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
name: Cache invalidation | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 7 1 * * | |
jobs: | |
delete: | |
name: Deleting | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
with: { fetch-depth: 0 } | |
- name: Install a GitHub CLI cache extension | |
run: gh extension install actions/gh-actions-cache | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cleanup caches | |
run: | | |
keys=$(gh actions-cache list -R '${{ github.repository }}' | cut -f1) | |
if [ -z "${keys}" ]; then echo 'Nothing to do' && exit 0; fi | |
echo Deleting caches... | |
for key in ${keys}; do | |
gh actions-cache delete "${key}" -R '${{ github.repository }}' --confirm || true | |
done | |
echo Done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
notify: | |
name: Notifying | |
needs: [ delete ] | |
runs-on: ubuntu-latest | |
if: failure() || success() | |
steps: | |
- name: Send Slack notification | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }} | |
SLACK_ICON: https://github.com/github.png?size=64 | |
SLACK_TITLE: '🧹 ${{ github.repository }}: ${{ github.workflow }}' | |
SLACK_USERNAME: GitHub Actions | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |