Edward Thomson

This is day 18 of my GitHub Actions Advent Calendar. If you want to see the whole list of tips as they're published, see the index.

When you build a workflow that performs pull request validation or continuous integration builds, you often want to take that build output and save it so that you can consume it later. Sometimes it makes sense to create a package and publish it up to a package registry like GitHub Packages. But sometimes you just want to store it as part of the build output that you can download later. GitHub Actions lets you upload artifacts as part of your workflow that you can download later.

To upload an artifact as part of your build, you can use the upload-artifact action. You can specify a path to create an artifact for – you can specify either an individual file or a folder, and a name for the artifact. The path that you specify will be archived into a zip file with the artifact name that you specified.

For example, I could build and test my project, then create a nuget package, and finally upload that nuget package as an artifact.

Now when my workflow runs, I'll get an option in the top right corner of that run, showing me my artifacts and letting me download them.

Uploading build output as artifacts can be useful alongside a package registry: I like to upload CI build packages to GitHub Packages, and create artifacts from pull request validation builds. This gives me the option of running and testing PR validation builds locally – I can just download them as artifacts – without cluttering up my GitHub Packages account. It's great when you want the option of running locally, even if you rarely do that.