Skip to content

Instantly share code, notes, and snippets.

@Madhust
Last active December 15, 2023 12:33
Show Gist options
  • Save Madhust/2d68feca9e50a635dd61577b50afe94b to your computer and use it in GitHub Desktop.
Save Madhust/2d68feca9e50a635dd61577b50afe94b to your computer and use it in GitHub Desktop.
Publish Blazor WebAssembly application to GitHub pages using GitHub Action
name: Deploy Blazor WASM to GitHub Page
env:
PUBLISH_DIR: bin/Release/net5.0/publish/wwwroot
# Controls when the action will run
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Publish application
run: dotnet publish -c Release
# base href url value should be changed so that resources like CSS and scripts can load properly.
- name: Rewrite base href
if: success()
uses: SteveSandersonMS/ghaction-rewrite-base-href@v1
with:
html_path: ${{ env.PUBLISH_DIR }}/index.html
base_href: BASE_URL or REPOSITORY_NAME
# add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore)
- name: Add .nojekyll file
run: touch ${{ env.PUBLISH_DIR }}/.nojekyll
- name: Commit to GitHub pages Repo
if: success()
uses: crazy-max/[email protected]
with:
target_branch: gh-pages
build_dir: ${{ env.PUBLISH_DIR }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment