Skip to content

Commit

Permalink
Add another manual workflow for lab/test builds of WASM to GH Pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
highbyte committed Oct 17, 2024
1 parent e7894ea commit 07f57c0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/dotnet-blazor-app-publish-to-gh-pages-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish Test .NET Blazor WASM app to GitHub Pages (separate url)

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-test"
BUILD_OUTPUT_WORKING_DIR: "build"
GH_PAGES_WORKING_DIR: "ghpages"
GH_PAGES_BRANCH_NAME: "gh-pages"

VERSION: "0.0.1-test" # Hardcoded version for test/lab builds

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
clean: false
clean-exclude: app/**/* # If clean: true, keep the live app folder in the gh-pages branch (where non lab/test builds are deployed to)
3 changes: 3 additions & 0 deletions .github/workflows/dotnet-blazor-app-publish-to-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ jobs:
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
clean: false
clean-exclude: app-test/**/* # If clean: true, keep the lab/test app folder in the gh-pages branch

0 comments on commit 07f57c0

Please sign in to comment.