mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-01 10:40:38 +00:00
4f363d2748
Cache saves have been rejected since June because the repo sat above its 10 GB allowance, so every PR run fell back to a cache built with an older toolchain and rebuilt the backend from scratch. - go version in the `gobuild` and `golint` keys and `restore-keys` - seeder triggers on `go.mod` and gained `workflow_dispatch` - single writer for the `gomod` cache, the two were racing - new daily `cache-prune` workflow holding the total under a limit - `cache: false` for `setup-go` in release and cron workflows, it held 815 MB - add `workflow_dispatch` so the cache workflows can be triggered on-demand Assisted-by: Claude Code:claude-opus-5
39 lines
1.2 KiB
YAML
39 lines
1.2 KiB
YAML
name: cache-prune
|
|
|
|
# Keeps the repository's total cache size below a fixed limit, so that GitHub never
|
|
# rejects a save for being over the allowance.
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "37 2 * * *" # every day at 02:37 UTC
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
|
|
permissions:
|
|
actions: write # to delete caches
|
|
|
|
concurrency:
|
|
group: cache-prune
|
|
|
|
jobs:
|
|
prune:
|
|
runs-on: ubuntu-latest
|
|
if: github.repository == 'go-gitea/gitea'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
GH_REPO: ${{ github.repository }}
|
|
steps:
|
|
# Deletes least recently used first, the order GitHub itself evicts in, which takes
|
|
# superseded generations first as those stop being restored once a newer one exists.
|
|
- name: delete caches over the size limit
|
|
run: |
|
|
caches=$(gh cache list --limit 1000 --sort last_accessed_at --order asc --json id,key,sizeInBytes)
|
|
size=$(jq '[.[].sizeInBytes] | add // 0' <<< "$caches")
|
|
echo "cache usage: $((size / 1000000)) MB"
|
|
jq -r '.[] | "\(.id) \(.sizeInBytes) \(.key)"' <<< "$caches" |
|
|
while [ "$size" -gt 6500000000 ] && read -r id bytes key; do
|
|
echo "deleting $key"
|
|
gh cache delete "$id"
|
|
size=$((size - bytes))
|
|
done
|