Skip to content

SadConsole improvements and updated documentation (#110) #20

SadConsole improvements and updated documentation (#110)

SadConsole improvements and updated documentation (#110) #20

name: Publish .NET Blazor WASM app to GitHub Pages
on:
# push:
# branches:
# - master
# workflow_dispatch:
#Trigger when tag is created
push:
tags:
- 'v*.*.*'
env:
CONFIGURATION: "Release"
PROJECT_FILE: "src/apps/Highbyte.DotNet6502.App.WASM/Highbyte.DotNet6502.App.WASM.csproj"
PROJECT_GH_PAGES_DIR: "app"
BUILD_OUTPUT_WORKING_DIR: "build"
GH_PAGES_WORKING_DIR: "ghpages"
GH_PAGES_BRANCH_NAME: "gh-pages"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v4
# Get version from tag
- name: Get version from tag with 'v' prefix
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
# Install .NET Core SDK
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install DotNet workload - WASM tools
run: |
dotnet workload install wasm-tools
# Create GitHub Pages root folder contents
- name: Create GH root folder and add .nojekyll file do disable built-in Jekyll CMS
run: |
mkdir ${{ env.GH_PAGES_WORKING_DIR }}
echo '' > ${{ env.GH_PAGES_WORKING_DIR }}/.nojekyll
# Publish the Blazor WASM site to a build working folder
- name: Publish
# Note: Could not get -p:GHPagesInjectBrotliLoader=true to work. Gets error "Uncaught ReferenceError: Blazor is not defined" from "brotliloader.min.js"
run: dotnet publish ${{ env.PROJECT_FILE }} -p:Version=${{ env.VERSION }} -c:${{ env.CONFIGURATION }} -p:GHPages=true -p:GHPagesBase="/${{ github.event.repository.name }}/${{ env.PROJECT_GH_PAGES_DIR }}/" -p:GHPagesInjectBrotliLoader=false -o:${{ env.BUILD_OUTPUT_WORKING_DIR }}/${{ env.PROJECT_GH_PAGES_DIR }}
# Copy the published Blazor WASM site from wwwroot folder in publish output dir
- name: Copy published wwwroot contents to a subdirectory in GH pages working dir root
run: |
cp -r ${{ env.BUILD_OUTPUT_WORKING_DIR }}/${{ env.PROJECT_GH_PAGES_DIR }}/wwwroot/ ${{ env.GH_PAGES_WORKING_DIR }}/${{ env.PROJECT_GH_PAGES_DIR }}/
# Deploy the Blazor WASM site
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
# token: ${{ secrets.ACCESS_TOKEN }} # Use if custom token needed to another repo
branch: ${{ env.GH_PAGES_BRANCH_NAME }} # The branch the action should deploy to.
folder: ${{ env.GH_PAGES_WORKING_DIR }} # The folder the action should deploy.
#target-folder: app #If not specified, the contents for folder above is copied to the root of the GH pages branch.
single-commit: true