|
1 | 1 | name: Deploy to GitHub Pages |
2 | | -# Run workflow on every push to the master branch |
| 2 | + |
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [ main ] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pages: write |
| 12 | + id-token: write |
| 13 | + |
| 14 | +# Allow one concurrent deployment |
| 15 | +concurrency: |
| 16 | + group: "pages" |
| 17 | + cancel-in-progress: true |
6 | 18 |
|
7 | 19 | jobs: |
8 | | - deploy-to-github-pages: |
9 | | - # use ubuntu-latest image to run steps on |
| 20 | + build: |
10 | 21 | runs-on: ubuntu-latest |
| 22 | + |
11 | 23 | steps: |
12 | | - #uses GitHub's checkout action to checkout code form the master branch |
13 | | - - uses: actions/checkout@v2 |
14 | | - # sets up .NET Core SDK 3.1 |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
15 | 26 | - name: Setup .NET Core SDK |
16 | | - uses: actions/setup-dotnet@v1 |
| 27 | + uses: actions/setup-dotnet@v4 |
17 | 28 | with: |
18 | | - dotnet-version: 8.0.0 |
19 | | - |
20 | | - # publishes Blazor project to the release-folder |
| 29 | + dotnet-version: 8.0.x |
| 30 | + |
21 | 31 | - name: Publish .NET Core Project |
22 | 32 | run: dotnet publish ModalAccessibilityTest.csproj -c Release -o release --nologo |
| 33 | + |
| 34 | + # Fix base path for GitHub Pages (CRITICAL for your app to work!) |
| 35 | + - name: Change base-tag in index.html |
| 36 | + run: sed -i 's/<base href="\/" \/>/<base href="\/Blazor-Modal-Accessibility-Testing\/" \/>/g' release/wwwroot/index.html |
| 37 | + |
| 38 | + # Add .nojekyll file to tell GitHub Pages to not process this as a Jekyll site |
| 39 | + - name: Add .nojekyll file |
| 40 | + run: touch release/wwwroot/.nojekyll |
| 41 | + |
| 42 | + # Copy index.html to 404.html for SPA routing |
| 43 | + - name: Copy index.html to 404.html |
| 44 | + run: cp release/wwwroot/index.html release/wwwroot/404.html |
| 45 | + |
| 46 | + - name: Upload artifact |
| 47 | + uses: actions/upload-pages-artifact@v3 |
| 48 | + with: |
| 49 | + path: release/wwwroot |
| 50 | + |
| 51 | + # Deploy job |
| 52 | + deploy: |
| 53 | + environment: |
| 54 | + name: github-pages |
| 55 | + url: ${{ steps.deployment.outputs.page_url }} |
| 56 | + runs-on: ubuntu-latest |
| 57 | + needs: build |
| 58 | + steps: |
| 59 | + - name: Deploy to GitHub Pages |
| 60 | + id: deployment |
| 61 | + uses: actions/deploy-pages@v4 |
0 commit comments