Files
bottom/.github/workflows/clear_workflow_cache.yml
T
Clement Tsang bb741a81da ci: run zizmor on GHA workflows (#2201)
Use zizmor to protect our workflows a bit better. Done buy running zizmor ./ --fix=unsafe-only.

We should also probably add zizmor to our CI pipeline.
2026-08-17 23:19:42 -04:00

50 lines
1.7 KiB
YAML

# Simple job to clear the cache used by a workflow.
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
schedule:
- cron: "0 11 * * 0"
permissions: {}
jobs:
clear-cache:
permissions:
actions: write
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
runs-on: ubuntu-24.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
persist-credentials: false
# 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
env:
GITHUB_EVENT_SCHEDULE: ${{ github.event.schedule }}
GITHUB_EVENT_INPUTS_ID: ${{ github.event.inputs.id }}