Skip to content

Refresh cache

Refresh cache #42

Workflow file for this run

name: Refresh cache
on:
schedule:
- cron: '0 2 * * 1' # Mondays at 2 AM UTC
workflow_dispatch:
permissions: {}
jobs:
clear_cache:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Delete old caches (except TestData)
env:
GH_TOKEN: ${{ github.token }}
run: |
cutoff=$(date -d '5 days ago' +%s)
gh api \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/actions/caches?per_page=100" \
--paginate \
--jq '.actions_caches[]' | \
jq -r --arg cutoff "$cutoff" '
select(.key | startswith("TestData-") | not) |
select((.last_accessed_at | sub("\\..*Z$"; "Z") | fromdateiso8601) < ($cutoff | tonumber)) |
"\(.id) \(.key)"
' | while read cache_id cache_key; do
if [ -n "$cache_id" ]; then
echo "Deleting cache $cache_id ($cache_key)"
gh api --method DELETE \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/actions/caches/$cache_id" || true
fi
done
cache:
runs-on: ubuntu-latest
outputs:
cache_key: ${{ steps.data_cache.outputs.cache_key }}
permissions:
actions: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- id: data_cache
uses: ./.github/actions/data-cache
- uses: ./.github/actions/native-data-cache
with:
cache_key: ${{ steps.data_cache.outputs.cache_key }}