How to publish artifacts in GitHub Actions?

· Category: DevOps & CI/CD

Short answer

Use actions/upload-artifact to save files from a workflow and actions/download-artifact to retrieve them in downstream jobs.

Steps

  1. Build or generate files in a job.
  2. Use actions/upload-artifact to store them.
  3. Use actions/download-artifact in another job.

Example

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run build
      - uses: actions/upload-artifact@v4
        with:
          name: build-output
          path: dist/

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: build-output
      - run: ./deploy.sh

Tips

  • Artifact names must be unique within a workflow run.
  • Use retention-days to control storage costs.
  • Large artifacts slow down upload and download times.

Common issues

  • Artifact names are case-sensitive.
  • Downloading an artifact that was not uploaded causes failure.
  • Artifact storage has size and retention limits.