Skip to content

one yml only

one yml only #6

# 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 - basicwebappusinggithub
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: self-hosted
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.x'
install-dir: ${{ runner.temp }}/dotnet
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: ${{ runner.temp }}/dotnet/dotnet publish -c Release -o "${{ runner.temp }}/myapp"
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
deploy:
runs-on: self-hosted
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_E497B02990D04A18AEC57EB2994ADDA9 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_7C7BAB7D5DDA44A58D6FA80BFD5CFB4F }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_DD2A1A7FD26449B9B33A297AA5ABD211 }}
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'basicwebappusinggithub'
slot-name: 'Production'
package: .