Upload and Download Artifacts
This document introduces how to pass build artifacts and files between Jobs using the upload-artifact and download-artifact plugins.
When you need to pass build artifacts (such as compilation results, test reports, packaged files, etc.) between jobs.
Prerequisites
- Confirmed the version of the artifact plugin being used.
- Confirmed that the size of the artifact does not exceed the limit.
Quick Example
name: build-and-package
on:
push:
branches:
- main
jobs:
build:
name: Build
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Checkout source code
uses: checkout
- name: Build
run: |
mkdir -p dist
echo "hello" > dist/app.txt
- name: Upload artifact
uses: upload-artifact
with:
name: app-dist
path: dist/
deploy:
name: Deploy
runs-on: [ubuntu-latest, x64, small]
needs: build
steps:
- name: Download artifact
uses: download-artifact
with:
name: app-dist
path: dist/
- name: Verify artifact
run: cat dist/app.txt
Configuration Instructions
Upload Artifact
steps:
- name: Upload artifact
uses: upload-artifact
with:
name: app-dist
path: dist/
| Parameter | Required | Description |
|---|---|---|
name | Yes | Name of the artifact, unique within the workflow |
path | Yes | Upload path, supports files and directories, supports glob patterns |
Upload multiple paths:
steps:
- name: Upload multiple paths
uses: upload-artifact
with:
name: build-output
path: |
dist/
reports/
coverage/
Download Artifact
steps:
- name: Download artifact
uses: download-artifact
with:
name: app-dist
path: dist/
| Parameter | Required | Description |
|---|---|---|
name | Yes | Name of the artifact to download |
path | No | Download target path, default is the current working directory |
Download all artifacts from the current workflow:
steps:
- name: Download all artifacts
uses: download-artifact
with:
path: artifacts/