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 upload artifact generated during the build process of an ASP.NET Web Application. This lab demonstrates the use of the actions/upload-artifact
action to store build outputs for later use.
Duration: 15-20 minutes
Before starting this lab, ensure that:
Refer to the ASP.NET Web App Upload Artifact Starter file for the initial workflow content.
Copy the content of the starter file:
name: ASP.NET Web App Upload Artifact
on:
push:
paths:
- '.github/workflows/aspnet-webapp-build-ubuntu-runner.yml'
- 'src/dotnet/WebApp/**'
workflow_dispatch:
jobs:
build:
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"
.github/workflows
and name it aspnet-webapp-upload-artifact.yml
.aspnet-webapp-build-upload-artifact.yml
file in your repository.Add a step to upload the generated artifact after the Publish Code
step. Update the jobs
section to include the following:
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.6
with:
name: aspnet-web-app # Artifact name
path: $/webapp # Path to the published artifact
aspnet-web-app
in this case).Ensure your aspnet-webapp-upload-artifact.yml
file matches the following:
name: ASP.NET Web App - Upload Artifact
on:
push:
paths:
- '.github/workflows/aspnet-webapp-upload-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
path: $/webapp
aspnet-webapp-upload-artifact.yml
file."Added workflow for uploading build artifact"
.build-and-upload
job executes successfully.aspnet-web-app
artifact is listed.In this lab, you extended the ASP.NET Web App build workflow to upload artifact using the actions/upload-artifact
action. You learned how to configure and trigger a new workflow for uploading build outputs and verified the artifact in GitHub Actions.
This version maintains the focus on the upload artifact functionality, with clear instructions for creating a new workflow dependent on the build workflow. Let me know if further adjustments are needed!