Skip to content

Add Azure Web App deployment workflow #8

Add Azure Web App deployment workflow

Add Azure Web App deployment workflow #8

Workflow file for this run

name: Publish
on:
workflow_dispatch:
push:
branches: [ master, main ]
env:
AZURE_WEBAPP_NAME: 'WebApiCICDWorkFlow' # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: './publish_output' # set this to the path to your web app project, defaults to the repository root
AZURE_WEBAPP_SLOT_NAME: 'production' # (optional) If a slot should be used, set the slot name here
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: Restore - Install dependencies
run: dotnet restore ./WebApiCICDWorkFlow.sln
- name: Build with dotnet
run: dotnet build ./WebApiCICDWorkFlow.sln --configuration Release --no-restore
- name: Test with dotnet
run: dotnet test ./WebApiCICDWorkFlow.Tests/WebApiCICDWorkFlow.Tests.csproj --configuration Release --verbosity normal
- name: Publish with dotnet
run: dotnet publish ./WebApiCICDWorkFlow.sln --configuration Release --no-build --output ${{env.AZURE_WEBAPP_PACKAGE_PATH}}
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: WebApiCICDWorkFlow_Production
path: ${{env.AZURE_WEBAPP_PACKAGE_PATH}}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
slot-name: ${{ env.AZURE_WEBAPP_SLOT_NAME }}
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
package: ${{env.AZURE_WEBAPP_PACKAGE_PATH}}