Skip to content

Refactor GitHub Actions workflow for Azure deployment #2

Refactor GitHub Actions workflow for Azure deployment

Refactor GitHub Actions workflow for Azure deployment #2

# 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 - Wrap-Studio
on:
push:
branches:
- main
workflow_dispatch:
env:
WEBAPP_NAME: Wrap-Studio
WEB_PROJECT: FilmProductionManagementSystem/Wrap.FilmProductionManagementSystem.Web/Wrap.FilmProductionManagementSystem.Web.csproj
PUBLISH_DIR: ${{ github.workspace }}/publish
jobs:
build:
runs-on: windows-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
- name: Restore
run: dotnet restore "${{ env.WEB_PROJECT }}"
- name: Build
run: dotnet build "${{ env.WEB_PROJECT }}" -c Release --no-restore
- name: Publish
run: dotnet publish "${{ env.WEB_PROJECT }}" -c Release -o "${{ env.PUBLISH_DIR }}" --no-build
- name: Upload artifact for deploy job
uses: actions/upload-artifact@v4
with:
name: webapp
path: ${{ env.PUBLISH_DIR }}
deploy:
runs-on: windows-latest
needs: build
permissions:
id-token: write
contents: read
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: webapp
path: webapp
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_81518D501E064914A73D3928C48694FB }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BF676D243FB8453D94A645550361FD9C }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C8131597CB3F401AA60F79FC004EF7F9 }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.WEBAPP_NAME }}
package: webapp