|
| 1 | +name: Deploy to GitHub Pages |
| 2 | + |
| 3 | +# Run workflow on every push to the master branch |
| 4 | +on: workflow_dispatch |
| 5 | + |
| 6 | +jobs: |
| 7 | + deploy-to-github-pages: |
| 8 | + permissions: |
| 9 | + contents: write |
| 10 | + # use ubuntu-latest image to run steps on |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + # uses GitHub's checkout action to checkout code form the master branch |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + |
| 16 | + # sets up .NET Core SDK |
| 17 | + - name: Setup .NET Core SDK |
| 18 | + uses: actions/setup-dotnet@v3.0.3 |
| 19 | + with: |
| 20 | + dotnet-version: '9' |
| 21 | + |
| 22 | + # Install dotnet wasm buildtools workload |
| 23 | + - name: Install .NET WASM Build Tools |
| 24 | + run: dotnet workload install wasm-tools wasm-tools-net8 |
| 25 | + |
| 26 | + # publishes Blazor project to the publish-folder |
| 27 | + - name: Publish .NET Core Project |
| 28 | + run: dotnet publish ./BlazorWASMWebGPUComputeDemo/ --nologo -c:Release --output publish |
| 29 | + |
| 30 | + # changes the base-tag in index.html from '/' to '/BlazorWASMWebGPUComputeDemo/' to match GitHub Pages repository subdirectory |
| 31 | + - name: Change base-tag in index.html from / to /BlazorWASMWebGPUComputeDemo/ |
| 32 | + run: sed -i 's/<base href="\/"/<base href="\/BlazorWASMWebGPUComputeDemo\/"/g' publish/wwwroot/index.html |
| 33 | + |
| 34 | + # copy index.html to 404.html to serve the same file when a file is not found |
| 35 | + - name: copy index.html to 404.html |
| 36 | + run: cp publish/wwwroot/index.html publish/wwwroot/404.html |
| 37 | + |
| 38 | + # add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore) |
| 39 | + - name: Add .nojekyll file |
| 40 | + run: touch publish/wwwroot/.nojekyll |
| 41 | + |
| 42 | + - name: Commit wwwroot to GitHub Pages |
| 43 | + uses: JamesIves/github-pages-deploy-action@v4.4.1 |
| 44 | + with: |
| 45 | + branch: gh-pages |
| 46 | + folder: publish/wwwroot |
0 commit comments