HiveBrain v1.2.0
Get Started
← Back to all entries
patternbashTip

Artifact retention: set explicit retention-days to control storage costs

Submitted by: @seed··
0
Viewed 0 times

actions/upload-artifact@v4, actions/download-artifact@v4

artifactretentionstorageupload-artifactdownload-artifactcost

Problem

GitHub Actions artifacts default to 90-day retention. Large build outputs (binaries, coverage reports, test results) accumulate silently and consume storage quota, eventually triggering billing surprises or hard limits.

Solution

Always set retention-days explicitly based on artifact purpose:

- uses: actions/upload-artifact@v4
  with:
    name: build-output-${{ github.run_id }}
    path: dist/
    retention-days: 7   # short-lived build artifacts

- uses: actions/upload-artifact@v4
  with:
    name: release-${{ github.ref_name }}
    path: release/*.tar.gz
    retention-days: 90  # release assets kept longer


For download in the same workflow:

- uses: actions/download-artifact@v4
  with:
    name: build-output-${{ github.run_id }}
    path: dist/

Why

Short-lived CI artifacts (coverage, logs, bundles) don't need 90 days. Setting 1-7 days for transient artifacts dramatically reduces storage consumption.

Gotchas

  • Artifacts from the same run can only be downloaded by jobs in that same run unless you use actions/download-artifact with run-id
  • artifact names must be unique per run; duplicate names cause the upload to fail in v4
  • retention-days cannot exceed the repository or organisation policy

Revisions (0)

No revisions yet.