-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (118 loc) · 4.29 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
133 lines (118 loc) · 4.29 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Deploy Docs
on:
push:
branches: [main]
paths:
- 'apps/docs/**'
- 'apps/his-demo/**'
- 'packages/**'
- '.github/workflows/deploy-docs.yml'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build workspace packages
# Builds every @fhir-dsl/* package (excludes apps/his-demo via the
# root build script's filter). Required so the @fhir-dsl/cli dist
# exists for the demo gen step below.
run: pnpm build
- name: Build Docusaurus
working-directory: apps/docs
run: pnpm build
- name: Generate FHIR types for demo
# npx needs --package because @fhir-dsl/cli's bin is named `fhir-gen`,
# not `cli` — npx can't auto-resolve. Explicit form fetches the package
# from npm and runs the right binary.
working-directory: apps/his-demo
run: npx -y --package=@fhir-dsl/cli fhir-gen generate --version r4 --validator native --expand-valuesets --resolve-codesystems --cache ./.fhir-cache --out ./src/fhir/r4
- name: Build demo (static SPA)
working-directory: apps/his-demo
env:
DEMO_STATIC: '1'
DEMO_BASE_PATH: /fhir-dsl/demo/
run: pnpm build
- name: Stage demo into docs build
run: |
set -euo pipefail
DEMO_SRC=apps/his-demo/dist/client
DEMO_DST=apps/docs/build/demo
mkdir -p "$DEMO_DST"
cp -R "$DEMO_SRC"/. "$DEMO_DST"/
# GitHub Pages serves /demo/ → /demo/index.html (root-route SPA shell);
# /demo/<deep-route> → /demo/404.html (which is the same SPA shell, so the
# client-side router handles the deep route after hydration).
cp "$DEMO_DST/_shell.html" "$DEMO_DST/index.html"
cp "$DEMO_DST/_shell.html" "$DEMO_DST/404.html"
echo "demo size: $(du -sh $DEMO_DST | cut -f1)"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: apps/docs/build
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
notify-search-engines:
needs: deploy
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Ping IndexNow (Bing, Yandex)
run: |
set -euo pipefail
KEY=00ead8a088444c033454e7c5d686592d
HOST=awbx.github.io
SITEMAP=https://awbx.github.io/fhir-dsl/sitemap.xml
# Wait briefly for the deploy edge to flush, then extract URLs from sitemap.
sleep 30
URLS=$(curl -sf "$SITEMAP" | grep -oE '<loc>[^<]+</loc>' | sed -E 's|</?loc>||g')
if [ -z "$URLS" ]; then
echo "No URLs found in sitemap; skipping IndexNow notify."
exit 0
fi
# Build the JSON payload (Bing IndexNow batch endpoint).
URL_LIST=$(echo "$URLS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
PAYLOAD=$(jq -n \
--arg host "$HOST" \
--arg key "$KEY" \
--arg keyLocation "https://$HOST/fhir-dsl/$KEY.txt" \
--argjson urls "$URL_LIST" \
'{host: $host, key: $key, keyLocation: $keyLocation, urlList: $urls}')
echo "Notifying IndexNow with $(echo "$URL_LIST" | jq 'length') URLs."
curl -sS -X POST "https://api.indexnow.org/IndexNow" \
-H "Content-Type: application/json; charset=utf-8" \
-H "Host: api.indexnow.org" \
--data "$PAYLOAD" \
-o /tmp/indexnow.txt -w "HTTP %{http_code}\n" || true
cat /tmp/indexnow.txt 2>/dev/null || true