Artifacts, Retention, Cross-Job Data, and Workflow Result Management: Configuration, Design Patterns, and Trade-Offs
Artifacts are a lifecycle and governance choice, not merely a file-transfer convenience. This lesson compares artifacts with caches and outputs, immutable identities with overwrite behavior, short and long retention, and diagnostic evidence with release deliverables.
Learning objectives
- Choose artifact, cache or job output from data purpose rather than YAML convenience.
- Explain current immutable artifact identity and why overwrite creates a replacement record rather than mutating history in place.
- Choose retention from evidence value, sensitivity, storage cost and organizational policy.
- Separate diagnostic/test artifacts from release deliverables and artifact attestations.
- Design cross-workflow consumption so run/SHA/trust identity is explicit.
1. Start from the data contract
Every persisted value should answer: who produces it, who consumes it, how large it is, whether it must survive the job/run, whether it is authoritative evidence, and whether it may contain sensitive data. That contract determines the transport.
2. Artifact versus cache versus output
| Scenario | Best mechanism | Why | Evidence |
|---|---|---|---|
Planner emits ["3.12","3.13"] |
job output |
small structured control data consumed through
needs
|
producer step + job output + consumer expression |
| Test suite creates HTML report/screenshots | artifact | file set must cross job/run boundary and be retained | artifact ID/digest/run/SHA/retention |
| Package-manager dependency directory | cache | reusable acceleration state; misses are acceptable | cache key/hit metadata + build timing |
| Release binary | artifact plus release/attestation policy | build output is authoritative and must carry provenance | artifact ID/digest + signed attestation/release record |
| Credential file | none | artifact/cache are not secret stores | secret manager/environment/OIDC evidence instead |
3. “Immutable” means identity changes when content changes
Current upload-artifact behavior does not append new files to an
existing artifact record. A same-name upload fails by default. If
overwrite: true is enabled, the action deletes the
artifact with that name and creates a new one. That means a new
ID/digest and a different lifecycle record.
For auditability, prefer unique names such as
tests-${{ github.run_id }}-${{ matrix.os }} and
preserve IDs. Use overwrite only when replacement semantics are
genuinely desired and the old evidence is not required.
# Evidence-friendly
name: tests-${{ github.run_id }}-${{ matrix.os }}
overwrite: false
# Replacement semantics: old record is deleted, new record is created
overwrite: true
4. Short versus long retention is a governance decision
| Artifact class | Typical retention intent | Questions before choosing |
|---|---|---|
| PR diagnostics | short | How long do reviewers need logs/screenshots? Is content sensitive? |
| CI coverage/test history | medium | Is long-term trend data stored elsewhere? What storage cost is acceptable? |
| Security incident evidence | policy-defined | Do legal/incident-response requirements require external records retention? |
| Release candidate/build | longer or promoted | Will the final release be copied to a release/package registry? Is attestation required? |
| Secrets/config credentials | zero | Do not upload; fix the data flow instead |
5. Compression affects latency and cost, not correctness
Upload-artifact supports compression levels 0–9, with 6 as the normal default. Highly compressible text benefits from higher compression; already-compressed binaries often waste CPU at high levels. Record non-default compression when performance comparisons matter, but do not treat compression as encryption.
6. Cross-run and cross-workflow downloads raise the trust bar
Downloading from the current workflow run can use the action's current-run context. Downloading from another run/repository requires an explicit token and run/repository identifiers. Treat the selected run as untrusted input until you prove its event, repository, head SHA and workflow trust.
- name: Download from an explicitly selected run
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: verified-build
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ inputs.source_run_id }}
path: ${{ runner.temp }}/incoming
digest-mismatch: error
A workflow_run or cross-run consumer may have more privilege than
the producer. Download into runner.temp, validate
identity/content, and never execute scripts from an untrusted
artifact merely because GitHub stored them.
7. Artifact digest and artifact attestation are complementary
The upload/download digest gives integrity for the GitHub artifact record. An artifact attestation is a signed provenance statement that ties a subject digest to build identity such as repository, workflow and commit claims. For releasable software, consumers must verify the attestation for it to provide security value. Chapter 23 covers attestations/SBOM provenance in depth.
8. Worked design scenario
A library tests Linux/Windows, publishes test reports, and creates a release tarball on tags. Use unique per-cell short-retention test artifacts, aggregate their evidence, then produce one release artifact with longer retention and an attestation. Do not reuse a dependency cache as release storage. The release pipeline should record exact source SHA, producing run, artifact ID/digest and attestation verification instructions.
Knowledge check
What happens when overwrite: true replaces an
artifact?
The existing same-name artifact is deleted and a new artifact record is created; identity/digest change.
Why is compression not a security control?
Compression changes representation/size and CPU cost; it does not provide confidentiality or authorization.
When is a job output preferable to an artifact?
For small structured control data such as IDs, versions or JSON that does not need file-style persistence.
What extra evidence is required for a cross-run artifact?
Explicit source run/repository, event/trust context, head SHA, artifact ID/digest and consumer verification.
Does generating an artifact attestation automatically secure consumers?
No. Consumers must verify the attestation and its policy claims; generation alone is not the security outcome.
Official references and version notes
- GitHub Docs — Workflow artifacts — artifact purpose, cache distinction and attestation context.
- GitHub Docs — Store and share data with workflow artifacts — upload/download, retention, cross-job transfer and digest validation.
- GitHub REST API — Actions artifacts — artifact ID, size, digest, expiration, download and delete endpoints.
-
actions/upload-artifact v7.0.1
— upload action pinned to
043fb46d1a93c77aae656e7c1c64a875d1fc6a0a. -
actions/download-artifact v8.0.1
— download action pinned to
3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c. - GitHub Docs — Artifact attestations — signed provenance is separate from ordinary artifact storage/digest verification.
Version-sensitive behavior was rechecked on
2026-09-09. Mandatory examples target GitHub.com
and ubuntu-24.04.
actions/upload-artifact v7.0.1 and
actions/download-artifact v8.0.1 are pinned by full
commit SHA. Upload v7 excludes dot-prefixed hidden files by
default, supports compression levels 0–9, returns artifact
ID/URL/SHA-256 digest, and treats overwrite as delete-and-create
rather than in-place mutation. Download v8 can select by artifact
ID and defaults digest mismatch handling to error.
Artifact/log retention is policy bounded: GitHub documents 1–90
days for public repositories and up to 400 days for private
repositories when repository/organization/enterprise policy
permits. Upload-artifact v4+ is not supported on GitHub Enterprise
Server; GHES users must use an appliance-compatible artifact
action/backend and must not copy GitHub.com majors blindly.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this
address.