Skip to content

CICD-464 · Cache storage cleanup ​

Encyclopedia · FinOps and resource optimization · All snippets

Previous · CICD-463 · Next · CICD-465

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites authorized read reports, explicit pricing period and reviewed ownership for cleanup.
  • Platforms github-actions, github-cli.
  • Parameters TARGET_REPO.

2. Copy the snippet ​

bash
gh cache list --repo "${TARGET_REPO:?}" --limit 100 --json id,key,lastAccessedAt,sizeInBytes > caches.json
jq 'sort_by(.lastAccessedAt) | .[:10]' caches.json

3. How it works ​

The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.

4. Verify the result ​

Consider active branches and reproducibility before removing old caches. Totals are bounded by the query limit.

Validation syntax-validated (Bash parse). Status definitions.