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 integrate the reusable workflow for deploying an ASP.NET Web App to Azure into a GitHub Actions pipeline. This will automate the deployment of your web application to Azure after building and publishing it.
.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-reusable-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: ./.github/workflows/azure-webapp-deploy-reusable-workflow.yml
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.uses: ./.github/workflows/azure-webapp-deploy-reusable-workflow.yml
syntax references the reusable workflow file for deploying the ASP.NET Web App to Azure.with
keyword passes the required parameters to the reusable 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 reusable workflow. By breaking the deployment logic into a reusable 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 reusable workflow.