Video Thumbnail for Lesson
4.2: Persisting Build Outputs with Artifacts

Persisting build outputs with artifacts

Actions runners are ephemeral—everything created during a job disappears when it finishes. Artifacts provide an escape hatch by storing files in GitHub's object storage so they can be downloaded later or consumed by downstream jobs.

jobs:
  artifact-producer:
    name: Produce artifact
    runs-on: ubuntu-24.04
    steps:
      - name: Create artifact file
        run: |
          echo "This will be stored as an artifact!" > artifact.txt
          echo "Generated by artifact-producer job on $(date)" >> artifact.txt

      - name: Upload artifact
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
        with:
          name: example-artifact
          path: artifact.txt

  artifact-consumer:
    name: Consume artifact
    runs-on: ubuntu-24.04
    needs: artifact-producer
    steps:
      - name: Download artifact
        uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
        with:
          name: example-artifact
      - name: Cat artifact file
        run: cat artifact.txt

Artifacts appear in the workflow run summary as downloadable ZIPs, making them great for sharing build assets, test reports, or any other files you may need to inspect after the job completes.