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 use a shared GitHub Actions workflow to deploy an ASP.NET Web App to Azure.
.github/workflows
directory in your GitHub repository.Create a new workflow YAML file for your main deployment pipeline. Name the file aspnet-webapp-deploy-to-azure-using-shared-workflow.yml
(or any preferred name).
The starter code for the main workflow is provided in Starter Template. Copy the code and paste it into the newly created workflow file.
needs: build
uses: prasadhonrao/github-actions-workshop-shared-repo/.github/workflows/deploy.yml@main
with:
AZURE_WEBAPP_PACKAGE_PATH: webapp
AZURE_WEBAPP_NAME: $
secrets:
AZURE_SERVICE_PRINCIPAL: $
needs: build
keyword ensures that the deployment job runs only after the build job is successful.prasadhonrao/github-actions-workshop-shared-repo/.github/workflows/deploy.yml@main
syntax references the shared workflow file for deploying the ASP.NET Web App to Azure.with
keyword passes the required parameters to the shared workflow:
AZURE_WEBAPP_PACKAGE_PATH
: The path to the published web app package.AZURE_WEBAPP_NAME
: The name of the Azure Web App to deploy.secrets
section provides the Azure Service Principal secret to authenticate the deployment workflow with Azure.For the deployment process to authenticate with Azure, you need to add the Azure Service Principal as a secret in your GitHub repository.
AZURE_SERVICE_PRINCIPAL
.{
"clientId": "<App-ID>",
"clientSecret": "<Secret>",
"tenantId": "<Tenant-ID>"
}
Once the workflow is set up, you can trigger the deployment in two ways:
Push to GitHub:
src/dotnet/WebApp/**
path or the workflow files (.github/workflows/aspnet-webapp-deploy.yml
).Manually Trigger the Workflow:
build
and deploy
jobs.In this lab, you successfully created a GitHub Actions workflow that builds an ASP.NET Web App, then deploys it to Azure using a shared workflow. By breaking the deployment logic into a shared workflow, you can easily reuse it across multiple projects, streamlining your CI/CD pipeline.
This concludes the lab on deploying an ASP.NET Web App to Azure using a shared workflow.