Skip to content

Use What, Why, How and Summary Components #250

Use What, Why, How and Summary Components

Use What, Why, How and Summary Components #250

name: build blazor app
on:
push:
branches:
- main
# Add paths to trigger the workflow on push to specific files or inside specific folders
# paths:
# - 'src/**'
paths-ignore:
- "**.md"
- ".github/workflows/codeql.yml"
pull_request:
branches:
- main
schedule:
# Runs every sunday 05.00 PM UTC (22.30 PM IST Equivalent). Pattern - "*(0-59 minute) *(0-23 hour) *(1-31 day of the month) *(1-12 month) *(0-6 day of the week)"
- cron: '0 17 * * 0'
workflow_dispatch: # Manually trigger the workflow
jobs:
build-test-deploy:
runs-on: ubuntu-latest
permissions: # can also be defined at the workflow level for all jobs
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
env:
DOTNET_NOLOGO: true #Disable welcome message
DOTNET_CLI_TELEMETRY_OPTOUT: true #Disable telemetry logs to be collected by Microsoft
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Install .NET WASM Build Tools
run: dotnet workload install wasm-tools
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20.11.1'
- run: npm install
working-directory: ./CommonComponents
- name: Restore dependencies
run: dotnet restore ./Web/Web.csproj
# Commented out the below steps as it is handled by NugitAudit properties in the csproj file starting .NET 8.0
# - name: Checking Vulnerable Nuget Packages
# run: |
# dotnet list ./Web/Web.csproj package --vulnerable --include-transitive --format=json > list.json
# # if jq -cre '.projects | .. | .severity? // empty | select(test("Critical|High"))' list.json; then
# if jq -cre '.projects | .. | .severity? // empty | select(test("Critical"))' list.json; then
# echo 'Vulnerabilities found! Exiting...'
# jq . list.json
# exit 1
# else
# echo 'No vulnerabilities found!'
# fi
# - name: Checking Outdated Nuget Packages
# run: dotnet list ./Web/Web.csproj package --outdated --include-transitive --format json
# - name: Checking Deprecated Nuget Packages
# run: dotnet list ./Web/Web.csproj package --deprecated --include-transitive --format json
- name: Build Blazor Project
run: dotnet build ./Web/Web.csproj --configuration Release --no-restore
- name: Install .NET Report Generator
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: Run Test
run: dotnet test ./UITests/UITests.csproj --configuration Release --verbosity normal --logger trx --collect:"XPlat Code Coverage"
#- name: Test Reporter
# uses: dorny/test-reporter@v1.7.0
# if: success() || failure()
# with:
# name: Unit Test Report
# path: '**/*.trx'
# reporter: dotnet-trx
- name: Generate Test Report
run: reportgenerator -reports:./**/Coverage.cobertura.xml -targetdir:"./Test/Report" -reporttypes:Html
- name: Upload Test Result
uses: actions/upload-artifact@v4
with:
name: ilovedotnet-test-report
path: ./Test/Report
retention-days: 1
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Publish Blazor Project
run: dotnet publish ./Web/Web.csproj -c:Release -p:GHPages=true --no-restore -o dist/Web --nologo
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: blazor-build-artifacts
path: dist/Web
# - name: Generate Release
# uses: softprops/action-gh-release@v2
# with:
# files: ./dist/Web/**/*
# body: "Binaries for Blazor Web App"
# tag_name: ${{ github.ref_name }}
# # if: startsWith(github.ref, 'refs/tags/')
# - name: Azure Static Web Apps Deploy
# uses: Azure/static-web-apps-deploy@v1
# with:
# azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
# action: "upload"
# ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
# app_location: "dist/Web/wwwroot" # App source code path
# api_location: "" # Api source code path - optional
# output_location: "" # Built app content directory - optional
# skip_app_build: true # Skip build - optional
# ###### End of Repository/Build Configurations ######
- name: Commit wwwroot to GitHub Pages
if: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
BRANCH: gh-pages
FOLDER: dist/Web/wwwroot
# build-test-deploy:
# runs-on: windows-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Setup Node.js environment
# run: npm install
# working-directory: ./CommonComponents
# - name: Restore dependencies
# run: dotnet restore
# # - name: Build MAUI Project
# # run: dotnet build ./MAUI/MAUI.csproj --configuration Release --no-restore