From 1b2090ecbd789cf272fa228dd94d63485dd6b42f Mon Sep 17 00:00:00 2001 From: Jeff Tian Date: Fri, 22 Mar 2024 13:03:41 +0800 Subject: [PATCH] docs(run-id): how to specify the run-id to the previous workflow's It took me 1 hour to figure out how to specify the run-id to the previous workflow's, so I document it here to save other's time hopefully! --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 6ed23d8..8be4fa8 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md). # The id of the workflow run where the desired download artifact was uploaded from. # If github-token is specified, this is the run that artifacts will be downloaded from. + # If your current workflow runs after another (triggered by `workflow_run`), you can specify the `run-id` to `${{ github.event.workflow_run.id }}` # Optional. Default is ${{ github.run_id }} run-id: ``` @@ -227,6 +228,24 @@ steps: run-id: 1234 ``` +Also, a common use case is to download artifacts from the previously completed workflow, then you can specify the `run-id` to `${{GitHub.event.workflow_run.id }}`: + +```yaml +on: + workflow_run: + workflows: [ "The name of the previous workflow" ] + types: + - completed + +steps: +- uses: actions/download-artifact@v4 + with: + name: my-other-artifact + github-token: ${{ secrets.GITHUB_TOKEN }} + repository: actions/toolkit + run-id: ${{ github.event.workflow_run.id }} +``` + ## Limitations ### Permission Loss