bottom/.github/workflows/clear-workflow-cache.yml

45 lines
1.4 KiB
YAML
Raw Normal View History

# 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."
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:
2022-11-06 11:46:51 +03:00
- name: Checkout repository
uses: actions/checkout@v3
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-master
sleep 5
python ./scripts/clear_cache.py keep-master
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