Build Blazor #89
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Blazor | |
on: | |
push: | |
branches: [ "master" ] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '7.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build and Publish | |
run: dotnet publish LaunchApp/LaunchApp.csproj -c Release -o ${{ runner.temp }}/published_app --no-self-contained | |
- name: Setup SPA routing and fix base href | |
run: | | |
cp ${{ runner.temp }}/published_app/wwwroot/index.html ${{ runner.temp }}/published_app/wwwroot/404.html | |
sed -i 's/base href="\/"/base href="\/${{ github.event.repository.name }}\/"/' ${{ runner.temp }}/published_app/wwwroot/index.html | |
sed -i 's/<script src="_framework\/blazor.webassembly.js"><\/script>/<script src="_framework\/blazor.webassembly.js" autostart="false"><\/script>/' ${{ runner.temp }}/published_app/wwwroot/index.html | |
- name: Deploy to GitHub Pages | |
run: | | |
git checkout --orphan gh-pages | |
git clean -fdx | |
git rm -rf . | |
cp -r ${{ runner.temp }}/published_app/wwwroot/. . | |
touch .nojekyll | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit -m "Deploy Blazor app to GitHub Pages" | |
git push -f origin gh-pages |