summaryrefslogtreecommitdiffstats
path: root/.github/workflows/clear_workflow_cache.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/clear_workflow_cache.yml')
-rw-r--r--.github/workflows/clear_workflow_cache.yml44
1 files changed, 44 insertions, 0 deletions
diff --git a/.github/workflows/clear_workflow_cache.yml b/.github/workflows/clear_workflow_cache.yml
new file mode 100644
index 00000000..6d6ca6c9
--- /dev/null
+++ b/.github/workflows/clear_workflow_cache.yml
@@ -0,0 +1,44 @@
+# Simple job to clear the cache used by a workflow. This automatically runs when a PR is closed/merged
+# to clean up the corresponding PR's cache.
+
+name: "clear workflow cache"
+
+on:
+ workflow_dispatch:
+ inputs:
+ id:
+ description: "Which id to clear. Type main/master/all to clean all, and keep-main/keep-master to clean all but the main branch."
+ required: false
+ pull_request:
+ types:
+ - closed
+ schedule:
+ - cron: "0 11 * * 0"
+
+jobs:
+ clear-cache:
+ runs-on: ubuntu-latest
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ fetch-depth: 1
+
+ # We run each script twice with a small delay in between to try and catch everything.
+ - name: Clear cache
+ run: |
+ if [[ -n "${{ github.event.schedule }}" ]]; then
+ python ./scripts/clear_cache.py keep-main
+ sleep 5
+ python ./scripts/clear_cache.py keep-main
+ elif [[ -z "${{ github.event.inputs.id }}" ]]; then
+ python ./scripts/clear_cache.py ${{ github.event.pull_request.number }}
+ sleep 5
+ python ./scripts/clear_cache.py ${{ github.event.pull_request.number }}
+ else
+ python ./scripts/clear_cache.py ${{ github.event.inputs.id }}
+ sleep 5
+ python ./scripts/clear_cache.py ${{ github.event.inputs.id }}
+ fi