-
Notifications
You must be signed in to change notification settings - Fork 7
181 lines (156 loc) · 6.33 KB
/
Copy pathdocs-preview.yml
File metadata and controls
181 lines (156 loc) · 6.33 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Build docs
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened, closed]
paths:
# Documentation pages and the browser playground shell.
- "docs/**"
- "playground/**"
# WASM playground server inputs. The WASM crate links the root server
# browser entry point, so request/IDE changes can affect PR previews.
- "src/**"
- "crates/**"
- "Cargo.toml"
- "Cargo.lock"
- "build.rs"
- "rust-toolchain.toml"
- ".github/actions/setup-emscripten/**"
- ".github/actions/setup-rust/**"
- ".github/actions/setup-sccache/**"
- ".github/workflows/docs-preview.yml"
- ".github/workflows/deploy-docs.yml"
permissions:
contents: read
env:
ASTRO_SITE: https://vide.pascal-lab.net
ASTRO_BASE: ${{ github.event_name == 'pull_request' && format('/preview/pr-{0}/', github.event.pull_request.number) || '/staging/' }}
PREVIEW_URL: ${{ github.event_name == 'pull_request' && format('https://vide.pascal-lab.net/preview/pr-{0}/', github.event.pull_request.number) || '' }}
STAGING_URL: https://vide.pascal-lab.net/staging/
EMSDK_VERSION: 5.0.2
jobs:
metadata:
name: Prepare preview metadata
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Write preview metadata
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_ACTION: ${{ github.event.action }}
run: |
set -euo pipefail
preview_path="preview/pr-${PR_NUMBER}/"
preview_url="https://vide.pascal-lab.net/${preview_path}"
mkdir -p preview-metadata
printf '%s\n' "${PR_NUMBER}" > preview-metadata/pr-number
printf '%s\n' "${PR_ACTION}" > preview-metadata/action
printf '%s\n' "${preview_path}" > preview-metadata/path
printf '%s\n' "${preview_url}" > preview-metadata/url
if [ "${PR_ACTION}" = "closed" ]; then
echo "Docs preview will be removed from ${preview_url}" >> "${GITHUB_STEP_SUMMARY}"
else
echo "Docs preview will be deployed to ${preview_url}" >> "${GITHUB_STEP_SUMMARY}"
fi
- name: Upload preview metadata
uses: actions/upload-artifact@v4
with:
name: vide-docs-preview-metadata
path: preview-metadata
retention-days: 7
build:
name: Build Starlight
if: github.event_name != 'pull_request' || github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore playground WASM cache
id: playground-wasm-cache
uses: actions/cache/restore@v4
with:
path: playground/public/wasm
key: playground-wasm-${{ runner.os }}-${{ env.EMSDK_VERSION }}-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'playground/scripts/build-vide-wasm.mjs', 'playground/scripts/script-utils.mjs', '.github/actions/setup-emscripten/**', '.github/actions/setup-rust/**') }}
- name: Verify cached playground WASM
if: steps.playground-wasm-cache.outputs.cache-hit == 'true'
run: |
test -s playground/public/wasm/vide-lsp.js
test -s playground/public/wasm/vide-core.js
test -s playground/public/wasm/vide-core.wasm
- name: Install Rust
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-rust
- name: Setup sccache
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-sccache
with:
cmake-launcher: "true"
- name: Rust Cache
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
uses: Swatinem/rust-cache@v2
continue-on-error: true
with:
shared-key: docs-wasm-${{ runner.os }}-${{ env.EMSDK_VERSION }}
key: wasm-src-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'playground/scripts/build-vide-wasm.mjs', 'playground/scripts/script-utils.mjs', '.github/actions/setup-emscripten/**', '.github/actions/setup-rust/**') }}
cache-workspace-crates: true
cache-on-failure: true
- name: Install Emscripten SDK
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-emscripten
with:
version: ${{ env.EMSDK_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: |
docs/package-lock.json
playground/package-lock.json
- name: Install playground dependencies
run: npm ci
working-directory: playground
- name: Build playground WASM
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
run: |
source "${EMSDK}/emsdk_env.sh"
npm run build:wasm
working-directory: playground
- name: Save playground WASM cache
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
continue-on-error: true
with:
path: playground/public/wasm
key: ${{ steps.playground-wasm-cache.outputs.cache-primary-key }}
- name: Install dependencies
run: npm ci
working-directory: docs
- name: Build docs
run: npm run build
working-directory: docs
- name: Add preview summary
if: github.event_name == 'pull_request'
run: |
set -euo pipefail
echo "Docs preview will be deployed to ${PREVIEW_URL}" >> "${GITHUB_STEP_SUMMARY}"
- name: Upload preview artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: vide-docs-preview
path: docs/dist
retention-days: 7
- name: Add master docs summary
if: github.event_name == 'push'
run: |
set -euo pipefail
echo "Master docs will be deployed to ${STAGING_URL}" >> "${GITHUB_STEP_SUMMARY}"
- name: Upload master docs artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: vide-docs-master
path: docs/dist
retention-days: 7