/ .github / workflows / deploy-pages.yml
deploy-pages.yml
 1  name: Deploy WebClient to GitHub Pages
 2  
 3  on:
 4    push:
 5      branches:
 6        - main
 7    workflow_dispatch:
 8  
 9  permissions:
10    contents: read
11  
12  concurrency:
13    group: pages
14    cancel-in-progress: false
15  
16  jobs:
17    build:
18      runs-on: ubuntu-latest
19      steps:
20        - name: Checkout
21          uses: actions/checkout@v6
22  
23        - name: Setup .NET
24          uses: actions/setup-dotnet@v5
25          with:
26            global-json-file: global.json
27  
28        - name: Publish WebClient
29          run: >
30            dotnet publish GUNRPG.WebClient/GUNRPG.WebClient.csproj
31            -c Release
32            -o publish
33  
34        - name: Fix base href for GitHub Pages subdirectory
35          run: >
36            sed -i 's|<base href="/" />|<base href="/${{ github.event.repository.name }}/" />|g'
37            publish/wwwroot/index.html
38  
39        - name: Add .nojekyll
40          run: touch publish/wwwroot/.nojekyll
41  
42        - name: Copy index.html to 404.html for SPA routing
43          run: cp publish/wwwroot/index.html publish/wwwroot/404.html
44  
45        - name: Upload Pages artifact
46          uses: actions/upload-pages-artifact@v4
47          with:
48            path: publish/wwwroot
49  
50    deploy:
51      needs: build
52      runs-on: ubuntu-latest
53      permissions:
54        pages: write
55        id-token: write
56      environment:
57        name: github-pages
58        url: ${{ steps.deployment.outputs.page_url }}
59      steps:
60        - name: Deploy to GitHub Pages
61          id: deployment
62          uses: actions/deploy-pages@v4