When you need to manually build and deploy your app, each time that you make a change, you will make mistakes, which result in bugs and downtime for users. Automating your build and deployment processes makes them less error-prone and allows you to deploy as often as you want.GitHub Actions can help to automate your builds and deployments and integrates withAzure App Service.
In this post, we'll automatically build and deploy code to an Azure App Service using GitHub Actions.
If you want to follow along, you'll need the following:
An Azure subscription (If you don't have an Azure subscription, create afree account before you begin)
An Azure App Service Web App. You can create one usingthis tutorial.
A GitHub account with a repository in it that contains code that can run on Azure App Service (like an ASP.NET Core website)
Create a GitHub Action from an Azure App Service
We already have an Azure App Service Web App, and a GitHub repository that contains an ASP.NET Core application. Let's use GitHub Actions to deploy the code from the repository to the Web App.
In the deployment center, selectGitHubas the source control location
If you haven't used your GitHub account with your Azure account before, you need to click theAuthorize buttonto authorize Azure to access GitHub
SelectContinueto go to the next step
In theBuild providersstep, selectGitHub Actions
(Select GitHub Actions in the Deployment Center)
In the Configure step:
Select theRepositorythat you want to use
Select the codeBranchto build and deploy from
Select theRuntime stack. In our case, this is.NET Corewith the latest version
(Configure GitHub access in the Deployment Center)
You'll now see the GitHub Action workflow configuration file that describes the GitHub action. SelectFinishto finalize the workflow
We have now successfully created a GitHub Action for the Azure Web App. After a few minutes, the workflow will be finished and the code from the repository should be deployed to the Web App. You should be able to see the deployed code run in the Web App when you click on theBrowsebutton from the Deployment Center.
(Application running in Azure App Service Web App)
And from the Deployment Center, you can click on theGitHub Action linkto go to the action in GitHub. Here, you can see all the GitHub Action workflows that are configured and their builds and deployments and drill down into the logs of already executed, or in-progress workflows.
(Details of a GitHub Action workflow)
Automating your build and deployment processes improves the quality of your software.GitHub Actions allow you to easily automate your builds and deployments and integrate withAzure App Service.