Skip to content

[Action] Renamed action #9

[Action] Renamed action

[Action] Renamed action #9

name: Build and deploy Blazor WASM app to github pages
on:
push:
branches: ['main']
env:
PUBLISH_DIR: output
WEBAPP_PATH: ./MyLife.Blazor.Wasm/
WEBAPP_CSPROJ: MyLife.Blazor.Wasm.csproj
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Change <base href="" /> in App.razor to match gh repo name
run: |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $NF}')
sed -i 's/<base href="\/" \/>/<base href="\/'$REPO_NAME'\/" \/>/g' ${{ env.WEBAPP_PATH }}wwwroot/index.html
- name: Publish .NET app
run: dotnet publish ${{ env.WEBAPP_PATH }}${{env.WEBAPP_CSPROJ}} --configuration Release -o ${{ env.WEBAPP_PATH }}${{env.PUBLISH_DIR}}
- name: copy index.html to 404.html AND add .nojekyll file (https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/)
run: |
cp ${{ env.WEBAPP_PATH }}${{env.PUBLISH_DIR}}/wwwroot/index.html ${{ env.WEBAPP_PATH }}${{env.PUBLISH_DIR}}/wwwroot/404.html
touch ${{ env.WEBAPP_PATH }}${{env.PUBLISH_DIR}}/wwwroot/.nojekyll
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.WEBAPP_PATH }}${{env.PUBLISH_DIR}}/wwwroot