Skip to content

CICD-101 · List artifact expiration state from CI ​

Encyclopedia · Artifact handoffs · All snippets

Previous · CICD-100 · Next · CICD-102

1. Where it fits ​

  • Placement Bash run step following checkout, or equivalent lab terminal.
  • Prerequisites actions runner, trusted producers and files actually generated by tests.
  • Platforms github-actions, github-cli.
  • Parameters GITHUB_REPOSITORY, GITHUB_RUN_ID.

2. Copy the snippet ​

bash
gh api "repos/${GITHUB_REPOSITORY:?}/actions/runs/${GITHUB_RUN_ID:?}/artifacts" --jq '.artifacts[] | [.name,.expired,.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 ​

Scope token reads to the current repository and verify the run ID.

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