Repository navigation
Clean up caches #248
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
| name: Clean up caches | |
| permissions: {} | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| workflow_run: | |
| workflows: | |
| - Build and test | |
| - Deploy release | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| inputs: | |
| scope: | |
| description: Which caches go | |
| required: true | |
| type: choice | |
| options: | |
| - superseded | |
| - all | |
| default: superseded | |
| ref: | |
| description: Ref or branch to clean. The one this runs from when empty. | |
| required: false | |
| type: string | |
| jobs: | |
| # A closed pull request's caches are reachable from its own ref alone, so | |
| # none of them can ever be restored again. | |
| after_a_pull_request: | |
| permissions: | |
| actions: write | |
| name: Delete every cache of the closed pull request | |
| # A fork's token is read only, so the deletion would fail rather than | |
| # leave anything behind. Those caches expire on their own after 7 days. | |
| if: >- | |
| github.event_name == 'pull_request' && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| uses: gigabit-clowns/.github/.github/workflows/clean-up-caches.yml@main | |
| with: | |
| scope: all | |
| ref: refs/pull/${{ github.event.pull_request.number }}/merge | |
| # Every ref: a superseded entry is dead wherever it sits, since the newest | |
| # of its prefix is the only one that will ever be restored. | |
| after_a_build: | |
| permissions: | |
| actions: write | |
| name: Delete the caches a newer run has replaced | |
| if: github.event_name == 'workflow_run' | |
| uses: gigabit-clowns/.github/.github/workflows/clean-up-caches.yml@main | |
| with: | |
| scope: superseded | |
| on_request: | |
| permissions: | |
| actions: write | |
| name: Delete ${{ inputs.scope }} caches | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: gigabit-clowns/.github/.github/workflows/clean-up-caches.yml@main | |
| with: | |
| scope: ${{ inputs.scope }} | |
| ref: ${{ inputs.ref != '' && inputs.ref || github.ref_name }} |