Skip to content
74 changes: 74 additions & 0 deletions .github/workflows/starter-no-infra_cloud-apps01.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 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 - cloud-apps01

on:
push:
branches:
- starter-no-infra
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read #This is required for actions/checkout

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0

- name: Build with dotnet
run: dotnet build --configuration Release

- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Install dotnet ef
run: dotnet tool install --global dotnet-ef --version 8.0.0

- name: Create migrations bundle
run: dotnet ef migrations bundle --runtime linux-x64 -o ${{env.DOTNET_ROOT}}/myapp/migrationsbundle

- 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
contents: read #This is required for actions/checkout

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_90D72AC14C0D42C6B79F71CC9F3B04AF }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_9312D2D840AC467BB75612E1D9D80515 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_7B05503C92A641249F2EF3CF3D3AC0A2 }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'cloud-apps01'
slot-name: 'Production'
package: .

2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
name: "default",
pattern: "{controller=Todos}/{action=Index}/{id?}");

app.Run();
app.Run();