@@ -58,15 +58,23 @@ jobs:
5858 dotnet restore
5959
6060 - name : Build Blazor WebAssembly
61- run : dotnet publish BlazorTextDiff.Web/BlazorTextDiff.Web.csproj -c Release -o dist/ -p:Version=${{ steps.version.outputs.version }}
62-
63- - name : Copy index.html to 404.html
64- run : cp dist/wwwroot/index.html dist/wwwroot/404.html
61+ run : dotnet publish BlazorTextDiff.Web/BlazorTextDiff.Web.csproj -c Release -o dist/ -p:Version=${{ steps.version.outputs.version }} -p:PublishUrl=/BlazorTextDiff/
6562
6663 - name : Add .nojekyll file
6764 run : touch dist/wwwroot/.nojekyll
6865
69- - name : Fix service-worker-assets.js hashes
66+ - name : Add version info to site
67+ working-directory : dist/wwwroot
68+ run : |
69+ BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
70+ echo "{\"version\":\"${{ steps.version.outputs.version }}\",\"buildDate\":\"$BUILD_DATE\",\"commit\":\"${{ github.sha }}\",\"run\":\"${{ github.run_id }}\"}" > version.json
71+ sed -i '/<\/head>/i \ \ \ \ <!-- Build: ${{ steps.version.outputs.version }} | Commit: ${{ github.sha }} | Run: ${{ github.run_id }} -->' index.html
72+
73+ - name : Change base-tag in index.html for GitHub Pages
74+ working-directory : dist/wwwroot
75+ run : sed -i 's|<base href="/" />|<base href="/BlazorTextDiff/" />|g' index.html
76+
77+ - name : Fix service-worker-assets.js hashes (if exists)
7078 working-directory : dist/wwwroot
7179 run : |
7280 jsFile=$(find . -name 'service-worker-assets.js' | head -1)
@@ -75,24 +83,13 @@ jobs:
7583 sed -i 's|"hash": "[^"]*"|"hash": "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="|g' "$jsFile"
7684 fi
7785
78- - name : Add version info to site
79- working-directory : dist/wwwroot
80- run : |
81- echo '{"version":"${{ steps.version.outputs.version }}","buildDate":"$(date -u +%Y-%m-%dT%H:%M:%SZ)","commit":"${{ github.sha }}","run":"${{ github.run_id }}"}' > version.json
82- echo "<!-- Build: ${{ steps.version.outputs.version }} | Commit: ${{ github.sha }} | Run: ${{ github.run_id }} -->" >> index.html
83-
84- - name : Change base-tag in index.html from / to BlazorTextDiff
85- working-directory : dist/wwwroot
86- run : sed -i 's/<base href="\/" \/>/<base href="\/BlazorTextDiff\/" \/>/g' index.html
87-
88- - name : copy index.html to 404.html
86+ - name : Copy index.html to 404.html for SPA routing
8987 working-directory : dist/wwwroot
9088 run : cp index.html 404.html
9189
9290 - name : Upload artifact
9391 uses : actions/upload-pages-artifact@v3
9492 with :
95- name : github-pages-${{ steps.version.outputs.version }}
9693 path : dist/wwwroot
9794
9895 deploy :
0 commit comments