How to Download an Artifact Into a Deploy Workflow in GitHub Actions
download-artifact with a run-id and github-token pulls a build from a different workflow run.
In the deploy workflow, call actions/download-artifact with run-id, the producing repo, and a token so it fetches the artifact from the CI run instead of the current one.
Steps
- Trigger the deploy via
workflow_runorworkflow_dispatch. - Call
download-artifactwithrun-idandgithub-token. - Deploy the restored files.
Workflow
.github/workflows/deploy.yml
on:
workflow_run:
workflows: [CI]
types: [completed]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./deploy.sh dist/Gotchas
- Cross-run downloads require both
run-idandgithub-token; omitting the token returns not found. - The token needs
actions: readto list artifacts from the other run.
Related guides
How to Set Artifact Retention Days in GitHub ActionsControl how long a GitHub Actions artifact is kept with the retention-days input on actions/upload-artifact,…
How to Upload a Coverage Report as an Artifact in GitHub ActionsAttach the generated HTML coverage report to a GitHub Actions run as a downloadable artifact with actions/upl…