Quick .NET Core Blazor Build/Test/Code Coverage/Publish/Deploy Github Action
21 Jul 2020 - Cody Merritt Anhorn
This article is just a quick snippet of code showing off a github action that will build a .NET Core application, test the application with code coverage, publish that code coverage to Codecov, publish a ASP.NET Core Blazor WASM application, and deploy the published Blazor application as an Azure Static Web App.
name: .NET Core on: push: branches: [ main ] pull_request: branches: [ main ] jobs: buildTestUpload: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: dotnet-version: 3.1.301 - name: Install dependencies run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore - name: Test run: dotnet test --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - name: Upload Coverage to Codecov uses: codecov/codecov-action@v1 with: token: $ file: ./Tests/Blazor.Tests/coverage.opencover.xml - name: .NET Publish run: dotnet publish --configuration Release -o published ./Source/Blazor.Website - name: Publish Static Site id: builddeploy uses: Azurefirstname.lastname@example.org with: azure_static_web_apps_api_token: $ action: "upload" app_location: "published/wwwroot" # App source code path app_artifact_location: "published/wwwroot" # Built app content directory - optional
Tags: .NET Core Github Blazor
Cody Merritt Anhorn