C.W.K.
Stream
Lesson 06 of 13 · published

Artifacts

~10 min · artifacts, upload, download

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Files that survive a single workflow run

An artifact is a file or directory uploaded by one job and downloadable from another job (in the same workflow run) or from the run UI for 90 days. Artifacts are how you pass data between jobs that run on different runners.

Common uses:

  • Test reports (JUnit XML, coverage HTML).
  • Build output (dist/, container images saved as tar).
  • Screenshots from end-to-end tests.
  • Logs and debug bundles when something fails.

The two actions

  • actions/upload-artifact@v4 — upload at the end of a job.
  • actions/download-artifact@v4 — download at the start of another job (same run only).

v4 is significantly faster than v3 (different storage backend) and changed the naming rules: artifact names within a run must be unique. If you have a matrix, include the matrix dimensions in the name.

Code

Upload + matrix-aware naming + download·yaml
jobs:
  test:
    strategy:
      matrix:
        python: ['3.10', '3.11', '3.12']
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pytest --junitxml=report.xml
      - if: always()
        uses: actions/upload-artifact@v4
        with:
          # name unique per matrix cell
          name: pytest-report-py${{ matrix.python }}
          path: report.xml
          retention-days: 14

  publish-report:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          # download every artifact whose name starts with pytest-report-
          pattern: pytest-report-*
          merge-multiple: true
      - run: ls -lah

External links

Exercise

Pick a workflow that runs tests. Make it upload the JUnit XML or coverage HTML as an artifact, with if: always(). Confirm you can download it from a failed run.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.