Skip to content

Instantly share code, notes, and snippets.

@tempous
Last active February 15, 2023 15:31
Show Gist options
  • Save tempous/7678eedccc26976d022ac531f3d4bff7 to your computer and use it in GitHub Desktop.
Save tempous/7678eedccc26976d022ac531f3d4bff7 to your computer and use it in GitHub Desktop.
Build and Deploy Blazor WASM to GitHub Pages
name: Build and Deploy Blazor WASM to GitHub Pages
on:
push:
branches: [main]
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Publish .NET Core Project
run: dotnet publish ${{ github.event.repository.name }}/${{ github.event.repository.name }}.csproj -c Release -o release --nologo
- name: Change base-tag in index.html from / to /repository subdirectory/
run: sed -i 's/<base href="\/" \/>/<base href="\/${{ github.event.repository.name }}\/" \/>/g' release/wwwroot/index.html
- name: Copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll
- name: Commit wwwroot to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: release/wwwroot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment