Skip to content

Commit

Permalink
create azure-webapps-dotnet-core.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
junioranheu authored Oct 30, 2024
1 parent 1d42dc4 commit ab39636
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/azure-webapps-dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and deploy .NET API app to Azure Web App

on:
push:
branches:
- main # Trigger on commits to the main branch
workflow_dispatch:

env:
DOTNET_VERSION: '8.x' # .NET SDK version to use
BUILD_CONFIGURATION: 'Release' # Build configuration
AZURE_WEBAPP_NAME: 'AuthAPI22' # Your Azure Web App name
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Azure publish profile secret

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore .NET dependencies
run: dotnet restore CodeGenerator.API/Auth.API.csproj

- name: Build .NET project
run: dotnet build CodeGenerator.API/Auth.API.csproj --configuration ${{ env.BUILD_CONFIGURATION }}

- name: Run unit tests
run: dotnet test CodeGenerator.API/Auth.API.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity normal

- name: Publish .NET project
run: dotnet publish CodeGenerator.API/Auth.API.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --output ${{ github.workspace }}/publish

- name: List published files
run: ls -R ${{ github.workspace }}/publish

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: dotnet-api
path: publish/

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: dotnet-api
path: download/

- name: List files in artifact
run: ls -R download/

- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: download/

0 comments on commit ab39636

Please sign in to comment.