-
Notifications
You must be signed in to change notification settings - Fork 17
142 lines (123 loc) · 4.22 KB
/
Copy pathpages.yml
File metadata and controls
142 lines (123 loc) · 4.22 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
134
135
136
137
138
139
140
141
142
name: Deploy Docs to GitHub Pages
on:
push:
branches: [ master, main ]
paths:
- 'docs/**'
# The desktop web demo (docs/demo) imports Desktop renderer sources;
# rebuild the site when they change so reuse drift fails the deploy.
- 'desktop/src/**'
- '.github/workflows/pages.yml'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: npm
cache-dependency-path: |
docs/package-lock.json
docs/demo/package-lock.json
- name: Setup Pages
id: pages
uses: actions/configure-pages@v6
- name: Install desktop demo dependencies
run: npm ci
working-directory: docs/demo
- name: Build desktop demo
run: npm run build
working-directory: docs/demo
- name: Install dependencies
run: npm ci
working-directory: docs
- name: Build site
run: npm run build
working-directory: docs
env:
VITEPRESS_BASE: ${{ steps.pages.outputs.base_path }}/
- name: Write build metadata
shell: bash
run: |
node <<'EOF'
const fs = require('node:fs')
const metadata = {
sha: process.env.GITHUB_SHA,
runId: process.env.GITHUB_RUN_ID,
runAttempt: process.env.GITHUB_RUN_ATTEMPT,
repository: process.env.GITHUB_REPOSITORY,
ref: process.env.GITHUB_REF,
basePath: process.env.VITEPRESS_BASE,
builtAt: new Date().toISOString()
}
fs.writeFileSync('docs/.vitepress/dist/build-info.json', `${JSON.stringify(metadata, null, 2)}\n`)
EOF
env:
VITEPRESS_BASE: ${{ steps.pages.outputs.base_path }}/
- name: Validate Pages artifact
shell: bash
run: |
set -euo pipefail
test -s docs/.vitepress/dist/index.html
test -d docs/.vitepress/dist/assets
test -s docs/.vitepress/dist/build-info.json
file_count=$(find docs/.vitepress/dist -type f | wc -l)
if [ "$file_count" -lt 10 ]; then
echo "::error::Pages artifact looks incomplete: only $file_count files"
exit 1
fi
echo "Pages artifact contains $file_count files"
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: docs/.vitepress/dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Verify published build
timeout-minutes: 5
shell: bash
env:
PAGE_URL: ${{ steps.deployment.outputs.page_url }}
EXPECTED_SHA: ${{ github.sha }}
run: |
set -euo pipefail
if [ -z "${PAGE_URL:-}" ]; then
echo "::error::deploy-pages did not return a page_url output"
exit 1
fi
info_url="${PAGE_URL%/}/build-info.json"
for attempt in {1..18}; do
rm -f build-info.remote.json
if curl -fsSL "$info_url" -o build-info.remote.json; then
actual_sha=$(node -e "const fs = require('node:fs'); const data = JSON.parse(fs.readFileSync('build-info.remote.json', 'utf8')); console.log(data.sha || '')" 2>/dev/null || true)
if [ "$actual_sha" = "$EXPECTED_SHA" ]; then
echo "Published build matches $EXPECTED_SHA"
exit 0
fi
echo "Published SHA is '${actual_sha:-<missing>}' at $info_url; waiting for $EXPECTED_SHA (attempt $attempt/18)"
else
echo "Could not fetch $info_url yet (attempt $attempt/18)"
fi
sleep 10
done
echo "::error::Pages did not serve build-info.json for $EXPECTED_SHA at $info_url"
exit 1