Script Valley
CI/CD with GitHub Actions
Building a CI PipelineLesson 2.5

How to upload and download build artifacts in GitHub Actions

actions/upload-artifact, actions/download-artifact, artifact retention, artifact naming, passing files between jobs, build output persistence

Why Artifacts?

Artifact upload and download between jobs

Each job runs on a fresh VM. Files created in one job do not exist in another. Artifacts solve this — they upload files to GitHub's storage so downstream jobs or humans can download them.

Uploading

- name: Build
  run: npm run build

- name: Upload build artifact
  uses: actions/upload-artifact@v4
  with:
    name: production-build
    path: dist/
    retention-days: 7

Downloading in Another Job

deploy:
  needs: build
  runs-on: ubuntu-latest
  steps:
    - name: Download build artifact
      uses: actions/download-artifact@v4
      with:
        name: production-build
        path: dist/

    - name: Deploy
      run: ./scripts/deploy.sh dist/

name — unique identifier for the artifact within the workflow run. path — file or directory to upload (upload) or where to place downloaded files (download). retention-days — how long GitHub stores the artifact (default 90, max 400). Artifacts are also downloadable from the workflow run page in the GitHub UI, useful for debugging build outputs.