Artifacts, Checksums and Provenance
Take one task-board application from local tests to a real delivery pipeline: continuous integration fundamentals, push and pull-request quality gates, lint, type-check, unit, component and end-to-end gates, dependency caching, matrix builds, artifacts and checksums, secrets and supply-chain security, release promotion, staging and production, rollback and observability.
What you will be able to do
#- Move a build output between jobs with upload and download.
- Apply artifact naming and retention rules.
- Explain how a checksum establishes artifact identity.
Overview
#Artifacts move bytes between jobs
An artifact is a file or directory a job uploads so another job or a human can download it. The common pattern is build once in a build job, upload the output, then download it in a deploy job. This guarantees the deployed bytes are exactly the tested bytes.
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable && pnpm install --frozen-lockfile
- run: pnpm build
- uses: actions/upload-artifact@v4
with:
name: web-dist
path: apps/web/dist
retention-days: 7
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: web-dist
path: dist
- run: echo deploying dist
Naming rules
An artifact name must be a simple string. Names containing path separators or special characters are rejected. Give artifacts short, descriptive names such as web-dist or coverage-report.
Checksums
A checksum is a hash of the artifact bytes. Recording the checksum lets a later step prove the downloaded artifact is identical to the uploaded one, and lets a release note publish a verifiable digest. Compute the hash after the build and store it next to the artifact.
sha256sum apps/web/dist.tar.gz > apps/web/dist.tar.gz.sha256
Retention
Artifacts consume storage. Set a retention period that matches how long the team needs the evidence. Test reports and traces are useful for days; release binaries may need to live longer.
Reproducible builds
A reproducible build produces the same bytes from the same source. Timestamps, absolute paths and unordered file listings break reproducibility. When a build is reproducible, the checksum becomes a strong identity for the release.
Sandbox boundary
The browser sandbox cannot upload or download CI artifacts. It can compute a hash of a string, which is the pure part of the checksum logic, but it cannot move bytes between jobs.
Exercises
#Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.
Exercise 1Implement
Add a build job that builds the app and uploads the dist directory as an artifact named web-dist, then a deploy job that depends on build and downloads it.
starter.yamljobs: build: runs-on: ubuntu-latest steps: - run: pnpm buildReveal the reference answer
reference.yamljobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: corepack enable && pnpm install --frozen-lockfile - run: pnpm build - uses: actions/upload-artifact@v4 with: name: web-dist path: apps/web/dist deploy: needs: build runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 with: name: web-dist path: distAuthored expected output: A build job that uploads web-dist and a deploy job that needs build and downloads web-dist.
needs: build makes the deploy wait for the artifact. Downloading the uploaded bytes means the deploy uses exactly what was built.
Exercise 2Debug
This artifact upload fails because the name contains a path separator. Fix the name.
starter.yaml- uses: actions/upload-artifact@v4 with: name: build/web-dist path: apps/web/distReveal the reference answer
reference.yaml- uses: actions/upload-artifact@v4 with: name: web-dist path: apps/web/distAuthored expected output: The artifact is named web-dist with no path separator.
Artifact names must be simple strings. A slash is rejected, so the upload fails before the artifact exists.
Exercise 3Test
Write a function validArtifactName(name) that returns true only for a non-empty name with no slash, backslash or whitespace.
starter.javascriptfunction validArtifactName(name) { // return true or false }Reveal the reference answer
reference.javascriptfunction validArtifactName(name) { if (typeof name !== 'string' || name.length === 0) return false; return !/[\/\\\s]/.test(name); }Authored expected output: validArtifactName('web-dist') is true; validArtifactName('build/web') is false.
The rule mirrors the platform constraint. Catching an invalid name in a pure function is cheaper than a failed upload.
Exercise 4Explain
Explain why you would record a checksum for an artifact you also deploy.
Reveal the reference answer
reference.textThe checksum is a fingerprint of the exact bytes. Recording it lets a later step or a user prove that the downloaded artifact is identical to the one that was built and tested. If the bytes change in transit or storage, the checksum no longer matches, so tampering or corruption is detectable.Authored expected output: A correct answer connects the checksum to identity and tamper detection.
A checksum turns an artifact into something verifiable. It is the difference between trusting bytes and proving them.
Common misconceptions
#- Each job should rebuild the app so it is fresh.
- Artifact names can contain paths.
- A checksum is only useful for security.
Follow-up practice
#- cicd-11-secrets-and-security
Your progress
#Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.
Verification: authored. Answers and outputs on this page are authored reference material, not executed results.