Upload and Download Artifacts
Use Case: 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:
runs-on: [ubuntu-latest, x64, small]
steps:
- 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:
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 Artifacts
steps:
- name: Upload artifact
uses: upload-artifact
with:
name: app-dist
path: dist/
| Parameter | Required | Description |
|---|---|---|
name | Yes | Artifact name, unique within the same workflow |
path | Yes | Upload path, supports files and directories, supports glob pattern |
Upload multiple paths:
steps:
- name: Upload multiple paths
uses: upload-artifact
with:
name: build-output
path: |
dist/
reports/
coverage/
Download Artifacts
steps:
- name: Download artifact
uses: download-artifact
with:
name: app-dist
path: dist/
| Parameter | Required | Description |
|---|---|---|
name | Yes | The name of the artifact to download |
path | No | The target path for download, defaults to the current working directory |
Download all artifacts from the current workflow:
steps:
- name: Download all artifacts
uses: download-artifact
with:
path: artifacts/