diff --git a/.github/workflows/dotnet-blazor-app-publish-to-gh-pages-beta.yml b/.github/workflows/dotnet-blazor-app-publish-to-gh-pages-beta.yml new file mode 100644 index 00000000..8ea7fb5d --- /dev/null +++ b/.github/workflows/dotnet-blazor-app-publish-to-gh-pages-beta.yml @@ -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) diff --git a/.github/workflows/dotnet-blazor-app-publish-to-gh-pages.yml b/.github/workflows/dotnet-blazor-app-publish-to-gh-pages.yml index c204ff23..4f624fa6 100644 --- a/.github/workflows/dotnet-blazor-app-publish-to-gh-pages.yml +++ b/.github/workflows/dotnet-blazor-app-publish-to-gh-pages.yml @@ -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 +