: It can specifically look for artifacts from a pull request. 3. Using the GitHub CLI ( gh )
- name: Download latest artifact from 'main' branch uses: dawidd6/action-download-artifact@v6 with: workflow: build.yml name: build-output workflow_conclusion: success branch: main path: ./downloaded-files Use code with caution. github actions download artifact from previous run
By default, the official actions/download-artifact is designed to fetch artifacts from the current workflow run. However, downloading artifacts from a —whether it's the latest successful build or a specific historical execution—is a common requirement for tasks like visual regression testing or incremental builds. : It can specifically look for artifacts from a pull request
- name: Get Last Successful Run ID id: last_run run: | RUN_ID=$(gh run list --workflow "My Workflow Name" --status success --limit 1 --json databaseId --jq '.[0].databaseId') echo "id=$RUN_ID" >> $GITHUB_OUTPUT env: GH_TOKEN: $ secrets.GITHUB_TOKEN - name: Download from Last Success uses: actions/download-artifact@v4 with: name: my-artifact run-id: $ steps.last_run.outputs.id github-token: $ secrets.GITHUB_TOKEN Use code with caution. 2. Using dawidd6/action-download-artifact (Recommended) 2. Using dawidd6/action-download-artifact (Recommended)