1+ name : Deploy Blazor to GitHub Pages
2+
3+ on :
4+ push :
5+ branches : [ main, master ]
6+ paths :
7+ - ' BlazorTextDiff.Web/**'
8+ - ' BlazorTextDiff/**'
9+ workflow_dispatch :
10+
11+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+ permissions :
13+ contents : read
14+ pages : write
15+ id-token : write
16+
17+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+ concurrency :
20+ group : " pages"
21+ cancel-in-progress : false
22+
23+ env :
24+ DOTNET_VERSION : ' 9.0.x'
25+
26+ jobs :
27+ build :
28+ runs-on : ubuntu-latest
29+ steps :
30+ - name : Checkout
31+ uses : actions/checkout@v4
32+
33+ - name : Setup .NET
34+ uses : actions/setup-dotnet@v4
35+ with :
36+ dotnet-version : ${{ env.DOTNET_VERSION }}
37+
38+ - name : Install .NET workloads
39+ run : dotnet workload install wasm-tools
40+
41+ - name : Setup Pages
42+ uses : actions/configure-pages@v5
43+
44+ - name : Restore dependencies
45+ run : |
46+ dotnet workload restore
47+ dotnet restore
48+
49+ - name : Build Blazor WebAssembly
50+ run : dotnet publish BlazorTextDiff.Web/BlazorTextDiff.Web.csproj -c Release -o dist/
51+
52+ - name : Copy index.html to 404.html
53+ run : cp dist/wwwroot/index.html dist/wwwroot/404.html
54+
55+ - name : Add .nojekyll file
56+ run : touch dist/wwwroot/.nojekyll
57+
58+ - name : Fix service-worker-assets.js hashes
59+ working-directory : dist/wwwroot
60+ run : |
61+ jsFile=$(find . -name 'service-worker-assets.js' | head -1)
62+ if [ ! -z "$jsFile" ]; then
63+ echo "Updating $jsFile"
64+ sed -i 's|"hash": "[^"]*"|"hash": "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="|g' "$jsFile"
65+ fi
66+
67+ - name : Change base-tag in index.html from / to BlazorTextDiff
68+ working-directory : dist/wwwroot
69+ run : sed -i 's/<base href="\/" \/>/<base href="\/BlazorTextDiff\/" \/>/g' index.html
70+
71+ - name : copy index.html to 404.html
72+ working-directory : dist/wwwroot
73+ run : cp index.html 404.html
74+
75+ - name : Upload artifact
76+ uses : actions/upload-pages-artifact@v3
77+ with :
78+ path : dist/wwwroot
79+
80+ deploy :
81+ environment :
82+ name : github-pages
83+ url : ${{ steps.deployment.outputs.page_url }}
84+ runs-on : ubuntu-latest
85+ needs : build
86+ steps :
87+ - name : Deploy to GitHub Pages
88+ id : deployment
89+ uses : actions/deploy-pages@v4
0 commit comments