Master GitHub Actions with hands-on labs and exercises. Learn how to automate workflows, run tests, deploy applications, and more using GitHub's powerful automation platform. This repository has everything you need to get started with continuous integration and continuous deployment.
In this lab, you will create a GitHub Actions workflow to download artifacts generated by a previous workflow. This demonstrates the use of the actions/download-artifact
action to retrieve stored artifacts for further use, such as deploying an ASP.NET Web Application.
Duration: 15-20 minutes
Before starting this lab, ensure that:
aspnet-web-app
.Refer to the ASP.NET Web App Download Artifact Starter file for the initial workflow content.
Copy the content of the starter file:
name: ASP.NET Web App Download Artifact
on:
workflow_dispatch:
jobs:
build-and-upload:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/dotnet/WebApp
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.7
- name: Set up .NET Core
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '8.x'
- name: Build Code
run: dotnet build --configuration Release
- name: Publish Code
run: dotnet publish -c Release --property:PublishDir="$/webapp"
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.6
with:
name: aspnet-web-app # Artifact name
path: $/webapp
.github/workflows
and name it aspnet-webapp-download-artifact.yml
.aspnet-webapp-download-artifact.yml
file.Add new job to download the artifact and list its contents:
download:
runs-on: ubuntu-latest
needs: build-and-upload
steps:
- name: Download Artifact
uses: actions/download-artifact@v4.1.8
with:
name: aspnet-web-app # Artifact name
- name: List Files in Artifact
run: |
ls -al
shell: bash
Ensure your aspnet-webapp-download-artifact.yml
file matches the following:
name: ASP.NET Web App - Download Artifact
on:
push:
paths:
- '.github/workflows/aspnet-webapp-download-artifact.yml'
- 'src/dotnet/WebApp/**'
workflow_dispatch:
jobs:
build-and-upload:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/dotnet/WebApp
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.7
- name: Set up .NET Core
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '8.x'
- name: Build Code
run: dotnet build --configuration Release
- name: Publish Code
run: dotnet publish -c Release --property:PublishDir="$/webapp"
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.6
with:
name: aspnet-web-app # Artifact name
path: $/webapp
retention-days: 7 # Number of days to keep the artifact. Default is 90 days or configured value in the repository settings -> Actions permissions -> Artifact and logs retention
download:
runs-on: ubuntu-latest
needs: build-and-upload
steps:
- name: Download Artifact
uses: actions/download-artifact@v4.1.8
with:
name: aspnet-web-app # Artifact name
- name: List Files in Artifact
run: |
ls -al
shell: bash
aspnet-webapp-download-artifact.yml
file."Added workflow for downloading build artifact"
.download
job executes successfully.downloaded-artifacts
directory.In this lab, you created a GitHub Actions workflow to download artifacts uploaded by a previous workflow using the actions/download-artifact
action. You verified the downloaded files and learned how to use them for subsequent steps in a CI/CD pipeline.