Skip to content

CICD-463 · Artifact storage cleanup ​

Encyclopedia · FinOps and resource optimization · All snippets

Previous · CICD-462 · Next · CICD-464

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 api --paginate "repos/${TARGET_REPO:?}/actions/artifacts" --jq '.artifacts[] | select(.expired) | [.id,.name,.expires_at] | @tsv'

3. How it works ​

The CLI calls the named GitHub API endpoint using current repository and token permissions. 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 ​

Inventory expired entries and verify audit-retention requirements before applying cleanup.

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