Skip to content

Instantly share code, notes, and snippets.

@Carl-Hugo
Last active February 13, 2024 23:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Carl-Hugo/721b848942083dc7739141a917a30653 to your computer and use it in GitHub Desktop.
Save Carl-Hugo/721b848942083dc7739141a917a30653 to your computer and use it in GitHub Desktop.
GitHub Action: Deploy Blazor WASM to GitHub Pages
name: Deploy Blazor WASM to GitHub Pages
on:
push:
branches: [main]
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.x
include-prerelease: true
- name: Publish .NET Core Project
run: dotnet publish src/YOUR_PROJECT_NAME/YOUR_PROJECT_NAME.csproj -c Release -o release --nologo
- 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@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: release/wwwroot
# Based on https://swimburger.net/blog/dotnet/how-to-deploy-aspnet-blazor-webassembly-to-github-pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment