Refresh cache #34
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: Refresh cache | |
| on: | |
| schedule: | |
| - cron: '0 2 * * 1' # Mondays at 2 AM UTC | |
| workflow_dispatch: | |
| 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 '14 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 }} | |
| 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 }} |