Skip to content

Create main.yml

Create main.yml #6

Workflow file for this run

name: Build and Deploy to Azure Web App Staging
on:
push:
branches:
- main # Or your target branch
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x' # Or your target version
- name: Restore dependencies
run: dotnet restore eShopOnWeb.sln
- name: Build solution
run: dotnet build eShopOnWeb.sln --configuration Release --no-restore
- name: Publish Web Project
run: dotnet publish ./src/Web/Web.csproj -c Release -o ./publish/web
- name: Publish PublicAPI Project
run: dotnet publish ./src/PublicApi/PublicApi.csproj -c Release -o ./publish/publicapi
- name: Deploy Web to Azure Staging Slot
uses: azure/webapps-deploy@v2
with:
app-name: 'eshopohweb' # No slot name here
slot-name: 'staging'
publish-profile: ${{ secrets.PUBLISH_PROFILE_WEBAPP1 }}
package: ./publish/web
- name: Deploy PublicAPI to Azure Staging Slot
uses: azure/webapps-deploy@v2
with:
app-name: 'eshopwebapiapp'
slot-name: 'staging'
publish-profile: ${{ secrets.PUBLISH_PROFILE_WEBAPP2 }}
package: ./publish/publicapi