Cache reaper #736
This file contains hidden or 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
| # - Keep the repository's Actions cache quota under control. | |
| # - On closed pull requests, delete all ccache and dependency caches for refs/pull/<N>/merge. | |
| # - On scheduled or manual runs, keep only the newest cache for each ref and configuration. | |
| # - This removes timestamped ccache duplicates and obsolete dependency-definition keys. | |
| name: Cache reaper | |
| on: | |
| pull_request: | |
| types: [closed] | |
| schedule: | |
| # Run every hour | |
| - cron: "0 * * * *" | |
| workflow_dispatch: | |
| # One reap per PR - scheduled/manual reaps share a single group. A newer run supersedes an in-flight one. | |
| concurrency: | |
| group: cache-reaper-${{ github.event.pull_request.number || 'scheduled' }} | |
| cancel-in-progress: true | |
| jobs: | |
| reap: | |
| # - Run independent pull-request cleanups in parallel; serialize scheduled and manual cleanup runs. | |
| if: github.repository == 'dragonflydb/dragonfly' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write # required to delete caches | |
| contents: read # required to check out the cache helper script | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| # Always source the helper from the current trusted default branch. | |
| # A PR's base commit can predate the time helper (actions_cache_ccache_helper.sh) was introduced - and job will fail. | |
| ref: ${{ github.event.repository.default_branch }} | |
| - name: Reap caches | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| PR_REF: refs/pull/${{ github.event.pull_request.number }}/merge | |
| run: | | |
| set -euo pipefail | |
| source "${GITHUB_WORKSPACE}/.github/actions/builder/scripts/actions_cache_ccache_helper.sh" | |
| actions_cache_ccache_reap "$GITHUB_EVENT_NAME" "$PR_REF" |