Skip to content

Move to GitHub actions #2

Move to GitHub actions

Move to GitHub actions #2

Workflow file for this run

name: Build and stage
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_VERSION: '8.0'
jobs:
build:
name: Build and publish app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up dependency caching for faster builds
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: dotnet restore
run: dotnet restore
- name: dotnet build
run: dotnet build --no-restore /p:TreatWarningsAsErrors=True
- name: dotnet test
run: dotnet test --logger trx --results-directory "${{ runner.temp }}" --no-build
- name: dotnet test
uses: NasAmin/trx-parser@v0.5.0
with:
TRX_PATH: "${{ runner.temp }}"
REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: dotnet publish
run: dotnet publish -o publish --no-build
- name: Upload artifact for deployment job
if: github.event_name != 'PullRequest'
uses: actions/upload-artifact@v4
with:
name: published-app
path: publish
deploy:
name: Deploy
needs:
- build
runs-on: ubuntu-latest
if: github.event_name != 'PullRequest'
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: published-app
- name: Log into Azure CLI with service principal
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
package: '.'
slot-name: 'production'