This GitHub Actions blog post will show how to create an artifact from a workflow \ pipeline.
Artifacts are beneficial in deployment pipelines because they allow us to store compiled code or build a single file and distribute it to users or applications.
Note: By default, artifacts are stored in GitHub Actions for 90 days and get deleted after. you can set a shorter limit in the code by using the following option retention-days: 10
In the following code example, I have a .NET application that I am building and at the end of the code, I create an artifact from it.
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: my-artifact
path: "./myApp"
Note: If you would like to give the artifact a random name remove the name option.
Below, you can see the end to end code.
name: Create a .NET app
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Create a new console app
run: dotnet new console -o myApp
- name: Run app
run: |
cd myApp
dotnet run
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: my-artifact
path: "./myApp"
Note: To upload multiple paths use the following code.
path: |
path/1
path/2
path/3
Once the artifact is fully uploaded, you will see it on the workflow summary page, as shown below.

For more GitHub Actions posts, please visit the category page.