Repository navigation
75 lines (62 loc) · 2.81 KB
/
Copy pathdeploy-pages.yml
File metadata and controls
75 lines (62 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Alternative to Azure Static Web Apps: publish the WASM app to GitHub Pages.
# Enable Pages in repo Settings → Pages → Source: "GitHub Actions", then this runs on push to main.
name: Deploy to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: "10.0.x"
- name: Publish
run: dotnet publish src/SignsOfAI.Web -c Release -o publish
# The Word task pane is its own WebAssembly app and ships under /word/. Office loads a task
# pane by URL, so an add-in whose SourceLocation 404s does not fail quietly: Word says "this
# add-in may not load properly" and the pane shows whatever the fallback served. That is
# exactly what happened the first time the manifest was sideloaded, because this step did not
# exist yet and Pages answered the pane's URL with the web app's SPA fallback.
- name: Publish the Word task pane
run: dotnet publish src/SignsOfAI.Word -c Release -o publish-word
# Project sites live at /<repo>/, so rewrite the base href from "/" to "/<repo>/".
- name: Rewrite base href
run: |
sed -i 's|<base href="/" />|<base href="/${{ github.event.repository.name }}/" />|g' publish/wwwroot/index.html
sed -i 's|<base href="/" />|<base href="/${{ github.event.repository.name }}/word/" />|g' publish-word/wwwroot/index.html
# SPA deep links (e.g. /catalog) 404 on Pages without a fallback — serve index.html as 404.
- name: SPA fallback
run: cp publish/wwwroot/index.html publish/wwwroot/404.html
- name: Place the task pane under /word/
run: cp -r publish-word/wwwroot publish/wwwroot/word
# The pane is loaded by URL from inside Word, where a 404 shows as an add-in error rather than
# a missing page. Fail the deploy here instead of finding out in Word.
- name: The task pane's own entry point exists
run: |
test -f publish/wwwroot/word/index.html
grep -q 'base href="/${{ github.event.repository.name }}/word/"' publish/wwwroot/word/index.html
grep -q '_framework/blazor.webassembly\.' publish/wwwroot/word/index.html
echo "word/index.html is in the artifact, with its own base href and a real bootstrap name."
- uses: actions/upload-pages-artifact@v5
with:
path: publish/wwwroot
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v5