الملفات
github-actions-demos/.github/workflows/dotnet.yml
Chris Ayers 74b13505ca fix pathing
2022-04-06 11:42:30 -07:00

94 أسطر
2.1 KiB
YAML

name: .NET
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
defaults:
run:
working-directory: dotnet-sample
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Set up dependency caching for faster builds
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: dotnet publish -c Release -o ./webapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: webapp
path: ./dotnet-sample/webapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: iac
path: ./dotnet-sample/iac
deploy-webapp:
needs: [build]
environment: dotnet
runs-on: ubuntu-latest
steps:
# Checkout code
- name: Download IaC
uses: actions/download-artifact@v2
with:
name: iac
path: iac
# Log into Azure
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Deploy Bicep file
- name: deploy
id: deploy
uses: azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
resourceGroupName: ${{ secrets.AZURE_RG }}
template: ./iac/main.bicep
parameters: webAppName=${{ secrets.AZURE_APP_NAME }}
failOnStdErr: false
- name: Download App
uses: actions/download-artifact@v2
with:
name: webapp
path: webapp
- name: 'Run Azure webapp deploy action using publish profile credentials'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ steps.deploy.outputs.webAppName }} # Replace with your app name
package: 'webapp'
- name: logout
run: |
az logout