Skip to content

Merge pull request #102 from dotnetcameroon/develop #60

Merge pull request #102 from dotnetcameroon/develop

Merge pull request #102 from dotnetcameroon/develop #60

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy ASP.Net Core app to Azure Web App - dotnetcameroon
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: dotnet publish ./app -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: App Settings Variable Substitution
uses: microsoft/variable-substitution@v1
with:
files: '${{env.DOTNET_ROOT}}/myapp/appsettings.Production.json'
env:
ConnectionStrings.SqlServer: ${{ secrets.AZURE_SQLSERVER_WEBSITE_DATABASE }}
ConnectionStrings.Npgsql: ${{ secrets.AZURE_POSTGRES_WEBSITE_DATABASE }}
ConnectionStrings.Sqlite: ${{ secrets.SQLITE_CONNECTION }}
CookiesOptions.Issuer: ${{ secrets.COOKIES_ISSUER}}
CookiesOptions.LoginPath: ${{ secrets.COOKIES_LOGINPATH}}
CookiesOptions.LogoutPath: ${{ secrets.COOKIES_LOGOUTPATH}}
CookiesOptions.AccessDeniedPath: ${{ secrets.COOKIES_ACCESSDENIEDPATH}}
CookiesOptions.ExpirationInDays: ${{ secrets.COOKIES_EXPIRATIONINDAYS}}
JwtOptions.Issuer: ${{ secrets.JWT_ISSUER}}
JwtOptions.Audience: ${{ secrets.JWT_AUDIENCE}}
JwtOptions.Secret: ${{ secrets.JWT_SECRET}}
JwtOptions.ExpirationInMinutes: ${{ secrets.JWT_EXPIRATION_IN_MINUTES}}
ApplicationInsights.InstrumentationKey: ${{ secrets.AZURE_APPINSIGHTS_INSTRUMENTAL_KEY}}
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: .net-app
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_EE54A09492B84A7FB617D1E8F7D1501F }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_147F0F1C25784E87A8BD4D7020FB737C }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_B905657052BB484DB6BE50F9C96A0077 }}
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'dotnetcameroon'
slot-name: 'Production'
package: .