From e470dfdd553777e62c8285bbeed42fa7b47b54cf Mon Sep 17 00:00:00 2001 From: David Sungaila Date: Sun, 19 Nov 2023 22:53:04 +0100 Subject: [PATCH] Add staging for GitHub Pages --- .github/workflows/githubpages.yml | 1 - .github/workflows/githubpages_staging.yml | 102 ++++++++++++++++++++++ WebConverter/wwwroot/index.html | 24 ++--- 3 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/githubpages_staging.yml diff --git a/.github/workflows/githubpages.yml b/.github/workflows/githubpages.yml index 861f975..944db18 100644 --- a/.github/workflows/githubpages.yml +++ b/.github/workflows/githubpages.yml @@ -4,7 +4,6 @@ name: GitHub Pages on: - workflow_dispatch: push: branches: - 'master' diff --git a/.github/workflows/githubpages_staging.yml b/.github/workflows/githubpages_staging.yml new file mode 100644 index 0000000..b6727bb --- /dev/null +++ b/.github/workflows/githubpages_staging.yml @@ -0,0 +1,102 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: GitHub Pages + +on: + workflow_dispatch: + pull_request: + branches: + - '**' + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@main + with: + fetch-depth: 0 + - name: Setup .NET 8 + uses: actions/setup-dotnet@main + with: + dotnet-version: 8.x + - name: Setup .NET workload android + run: dotnet workload install android + - name: Setup .NET workload wasm-tools + run: dotnet workload install wasm-tools + - name: Setup .NET workload wasm-tools-net7 + run: dotnet workload install wasm-tools-net7 + - name: Update relative paths + working-directory: WebConverter/wwwroot + run: | + sed -i 's///g' index.html + sed -i 's/"scope": "\/"/"scope": "\/${{github.event.repository.name}}\/"/g' manifest.webmanifest + sed -i 's/"start_url": "\/"/"start_url": "\/${{github.event.repository.name}}\/"/g' manifest.webmanifest + sed -i 's/"action": "\/"/"action": "\/${{github.event.repository.name}}\/"/g' manifest.webmanifest + sed -i 's/"action": "\/receive-webshare"/"action": "\/${{github.event.repository.name}}\/receive-webshare"/g' manifest.webmanifest + - name: Restore + run: dotnet restore PDFtoZPL.sln + - name: Publish + run: dotnet publish WebConverter/WebConverter.csproj -c Release -p:PublishProfile=WebConverter/Properties/PublishProfiles/PublishSite.pubxml --no-restore + - name: Create .nojekyll file + run: touch WebConverter/bin/Release/net7.0/publish/wwwroot/.nojekyll + - name: Update service-worker-assets.js hashes + working-directory: WebConverter/bin/Release/net7.0/publish/wwwroot + if: false + run: | + jsFile=$( service-worker-assets.js + - name: Upload pages artifact + uses: actions/upload-pages-artifact@main + with: + path: WebConverter/bin/Release/net7.0/publish/wwwroot + deploy: + name: Deploy + needs: publish + runs-on: ubuntu-latest + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + environment: + name: github-pages-staging + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@main + with: + preview: true \ No newline at end of file diff --git a/WebConverter/wwwroot/index.html b/WebConverter/wwwroot/index.html index 3bef710..37f7a0c 100644 --- a/WebConverter/wwwroot/index.html +++ b/WebConverter/wwwroot/index.html @@ -106,20 +106,20 @@