Github how to download artifacts
Github how to download artifacts
Downloading workflow artifacts
You can download archived artifacts before they automatically expire.
By default, GitHub stores build logs and artifacts for 90 days, and you can customize this retention period, depending on the type of repository. For more information, see «Managing GitHub Actions settings for a repository.»
Read access to the repository is required to perform these steps.
On GitHub.com, navigate to the main page of the repository.
Under your repository name, click
Actions.
In the left sidebar, click the workflow you want to see.
From the list of workflow runs, click the name of the run to see the workflow run summary.
Under Artifacts, click the artifact you want to download.
To learn more about GitHub CLI, see «About GitHub CLI.»
GitHub CLI will download each artifact into separate directories based on the artifact name. If only a single artifact is specified, it will be extracted into the current directory.
To download a specific artifact from a run, use the run download subcommand. Replace run-id with the ID of the run that you want to download artifacts from. Replace artifact-name with the name of the artifact that you want to download.
You can specify more than one artifact.
To download specific artifacts across all runs in a repository, use the run download subcommand.
Help us make these docs great!
All GitHub docs are open source. See something that’s wrong or unclear? Submit a pull request.
Mark Vincze
Software Developer
Download artifacts from a latest GitHub release with bash and PowerShell
Releases is an important feature of GitHub, with which we can publish packaged versions of our project.
The source code of our repository is packaged with every release, and we also have the possibility to upload some artifacts alongside, for example the binaries or executables that we’ve built.
Lately I’ve been working on an application for which the releases are published on GitHub, and I wanted to create an install script which always downloads the latest release.
It turned out that downloading the artifacts for a specific version is easy, we can simply build an URL with the version number to access the artifact. However, there is no direct URL to download artifacts from the latest release, so we need a bit of logic in our scripts to do that.
Link structure
Getting the latest tag
As it’s pointed out in the above SO answer, we can send a GET request to the URL https://github.com/account/project/releases/latest and set the Accept header to application/json (without this we get back the HTML page), we get information about the latest release in the following format.
This is the information we want, now we can use this in our scripts to determine the latest version and build our download links.
Use the version in scripts
Shell script
Then we can build our download URL for a certain artifact.
PowerShell
Then we have to extract the value of the tag_name property. Since PowerShell has built-in support for parsing Json, we don’t have to use a regex.
Then we can build our download URL for a certain artifact.
© 2020 Mark Vincze. All rights reserved.
Built with Hugo and Bulma. 💙
Storing workflow data as artifacts
In this article
Artifacts allow you to share data between jobs in a workflow and store data once that workflow has completed.
About workflow artifacts
Artifacts allow you to persist data after a job has completed, and share that data with another job in the same workflow. An artifact is a file or collection of files produced during a workflow run. For example, you can use artifacts to save your build and test output after a workflow run has ended. All actions and workflows called within a run have write access to that run’s artifacts.
By default, GitHub stores build logs and artifacts for 90 days, and this retention period can be customized. For more information, see «Usage limits, billing, and administration.» The retention period for a pull request restarts each time someone pushes a new commit to the pull request.
These are some of the common artifacts that you can upload:
Storing artifacts uses storage space on GitHub. GitHub Actions usage is free for both public repositories and self-hosted runners. For private repositories, each GitHub account receives a certain amount of free minutes and storage, depending on the product used with the account. Any usage beyond the included amounts is controlled by spending limits. For more information, see «Managing billing for GitHub Actions.»
Artifacts are uploaded during a workflow run, and you can view an artifact’s name and size in the UI. When an artifact is downloaded using the GitHub UI, all files that were individually uploaded as part of the artifact get zipped together into a single file. This means that billing is calculated based on the size of the uploaded artifact and not the size of the zip file.
GitHub provides two actions that you can use to upload and download build artifacts. For more information, see the actions/upload-artifact and download-artifact actions.
To share data between jobs:
The steps of a job share the same environment on the runner machine, but run in their own individual processes. To pass data between steps in a job, you can use inputs and outputs. For more information about inputs and outputs, see «Metadata syntax for GitHub Actions.»
Comparing artifacts and dependency caching
Artifacts and caching are similar because they provide the ability to store files on GitHub, but each feature offers different use cases and cannot be used interchangeably.
For more information on dependency caching, see «Caching dependencies to speed up workflows.»
Uploading build and test artifacts
You can create a continuous integration (CI) workflow to build and test your code. For more information about using GitHub Actions to perform CI, see «About continuous integration.»
The output of building and testing your code often produces files you can use to debug test failures and production code that you can deploy. You can configure a workflow to build and test the code pushed to your repository and report a success or failure status. You can upload the build and test output to use for deployments, debugging failed tests or crashes, and viewing test suite coverage.
You can use the upload-artifact action to upload artifacts. When uploading an artifact, you can specify a single file or directory, or multiple files or directories. You can also exclude certain files or directories, and use wildcard patterns. We recommend that you provide a name for an artifact, but if no name is provided then artifact will be used as the default name. For more information on syntax, see the actions/upload-artifact action.
For example, your repository or a web application might contain SASS and TypeScript files that you must convert to CSS and JavaScript. Assuming your build configuration outputs the compiled files in the dist directory, you would deploy the files in the dist directory to your web application server if all tests completed successfully.
This example shows you how to create a workflow for a Node.js project that builds the code in the src directory and runs the tests in the tests directory. You can assume that running npm test produces a code coverage report named code-coverage.html stored in the output/test/ directory.
The workflow uploads the production artifacts in the dist directory, but excludes any markdown files. It also uploads the code-coverage.html report as another artifact.
Configuring a custom artifact retention period
You can define a custom retention period for individual artifacts created by a workflow. When using a workflow to create a new artifact, you can use retention-days with the upload-artifact action. This example demonstrates how to set a custom retention period of 5 days for the artifact named my-artifact :
The retention-days value cannot exceed the retention limit set by the repository, organization, or enterprise.
Downloading or deleting artifacts
During a workflow run, you can use the download-artifact action to download artifacts that were previously uploaded in the same workflow run.
After a workflow run has been completed, you can download or delete artifacts on GitHub or using the REST API. For more information, see «Downloading workflow artifacts,» «Removing workflow artifacts,» and the «Artifacts REST API.»
Downloading artifacts during a workflow run
The actions/download-artifact action can be used to download previously uploaded artifacts during a workflow run.
Note: You can only download artifacts in a workflow that were uploaded during the same workflow run.
You can also download all artifacts in a workflow run by not specifying a name. This can be useful if you are working with lots of artifacts.
If you download all workflow run’s artifacts, a directory for each artifact is created using its name.
For more information on syntax, see the actions/download-artifact action.
Passing data between jobs in a workflow
You can use the upload-artifact and download-artifact actions to share data between jobs in a workflow. This example workflow illustrates how to pass data between jobs in the same workflow. For more information, see the actions/upload-artifact and download-artifact actions.
Job 1 performs these steps:
Job 2 uses the result in the previous job:
Job 3 displays the result uploaded in the previous job:
The workflow run will archive any artifacts that it generated. For more information on downloading archived artifacts, see «Downloading workflow artifacts.»
dawidd6/action-download-artifact
Use this GitHub Action with your project
Add this Action to an existing workflow or create a new one.
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Download workflow artifact GitHub Action
An action that downloads and extracts uploaded artifacts associated with a given workflow and commit or other criteria.
Let’s suppose you have a workflow with a job in it that at the end uploads an artifact using actions/upload-artifact action and you want to download this artifact in another workflow that is run after the first one. Official actions/download-artifact does not allow this. That’s why I decided to create this action. By knowing only the workflow name and commit SHA, you can download the previously uploaded artifact from different workflow associated with that commit and use it.
If commit or pr or branch or run_id or workflow_conclusion is not specified then the artifact from the most recent successfully completed workflow run will be downloaded.
About
⚙️ A GitHub Action to download an artifact associated with given workflow and commit or other criteria
actions/download-artifact
Use this GitHub Action with your project
Add this Action to an existing workflow or create a new one.
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
This downloads artifacts from your build
Refer here for the previous version
Download a Single Artifact
Basic (download to the current working directory):
Download to a specific directory:
Basic tilde expansion is supported for the path input:
Compatibility between v1 and v2 / v3
Download All Artifacts
Download all artifacts to a specific directory
Download all artifacts to the current working directory
Download path output
The download-path step output contains information regarding where the artifact was downloaded to. This output can be used for a variety of purposes such as logging or as input to other actions. Be aware of the extra directory that is created if downloading all artifacts (no name specified).
Note: The id defined in the download/artifact step must match the id defined in the echo step (i.e steps.[ID].outputs.download-path )
❗ File permissions are not maintained during artifact upload ❗ For example, if you make a file executable using chmod and then upload that file, post-download the file is no longer guaranteed to be set as an executable.
Case Insensitive Uploads
❗ File uploads are case insensitive ❗ If you upload A.txt and a.txt with the same root path, only a single file will be saved and available during download.
Maintaining file permissions and case sensitive files
If file permissions and case sensitivity are required, you can tar all of your files together before artifact upload. Post download, the tar file will maintain file permissions and case sensitivity.
Internally the @actions/artifact NPM package is used to interact with artifacts. You can find additional documentation there along with all the source code related to artifact download.
The scripts and documentation in this project are released under the MIT License