-
-
Notifications
You must be signed in to change notification settings - Fork 5
150 lines (126 loc) · 5.51 KB
/
build-blazor-app.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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