-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (131 loc) · 4.24 KB
/
deploy-docs.yml
File metadata and controls
155 lines (131 loc) · 4.24 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
name: Deploy VitePress Documentation to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: pages
cancel-in-progress: false
on:
push:
branches: [main]
paths:
- "hypnoscript-docs/**"
- ".github/workflows/deploy-docs.yml"
- "hypnoscript-*/src/**"
- "README.md"
pull_request:
branches: [main]
paths:
- "hypnoscript-docs/**"
- "hypnoscript-*/src/**"
jobs:
build:
runs-on: ubuntu-latest
env:
RUST_DOC_SRC: target/doc
RUST_DOC_OUTPUT: rust-docs
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # For VitePress lastUpdated feature
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Build Rust documentation
run: |
cargo doc --no-deps --workspace --release
- name: Ensure rust source dir exists
run: |
if [ ! -d "${RUST_DOC_SRC}" ]; then
echo "'rust-src-dir' does not point to an existing directory"
echo "The value of 'rust-src-dir' is: ${RUST_DOC_SRC}"
exit 1
fi
mkdir -p "${RUST_DOC_OUTPUT}"
cp -r "${RUST_DOC_SRC}/." "${RUST_DOC_OUTPUT}/"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: hypnoscript-docs/package-lock.json
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install Dependencies
working-directory: hypnoscript-docs
run: npm ci
- name: Build VitePress Documentation
working-directory: hypnoscript-docs
run: npm run build
- name: Copy Rust docs to build directory
run: |
mkdir -p hypnoscript-docs/docs/.vitepress/dist/rust-api
cp -r "${RUST_DOC_OUTPUT}/." hypnoscript-docs/docs/.vitepress/dist/rust-api/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: hypnoscript-docs/docs/.vitepress/dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Optional: Build and test on PR
test-build:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
env:
RUST_DOC_SRC: target/doc
RUST_DOC_OUTPUT: rust-docs
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Build Rust documentation
run: cargo doc --no-deps --workspace --release
- name: Ensure rust source dir exists
run: |
if [ ! -d "${RUST_DOC_SRC}" ]; then
echo "'rust-src-dir' does not point to an existing directory"
echo "The value of 'rust-src-dir' is: ${RUST_DOC_SRC}"
exit 1
fi
mkdir -p "${RUST_DOC_OUTPUT}"
cp -r "${RUST_DOC_SRC}/." "${RUST_DOC_OUTPUT}/"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: hypnoscript-docs/package-lock.json
- name: Install Dependencies
working-directory: hypnoscript-docs
run: npm ci
- name: Build VitePress Documentation
working-directory: hypnoscript-docs
run: npm run build
- name: Check for broken links
working-directory: hypnoscript-docs
run: |
npm install --no-save linkinator@^3 wait-on@^7
npx vitepress preview docs --host 127.0.0.1 --port 4173 &
PREVIEW_PID=$!
trap 'kill $PREVIEW_PID 2>/dev/null || true' EXIT
npx wait-on http://127.0.0.1:4173/hyp-runtime/
npx linkinator http://127.0.0.1:4173/hyp-runtime/ --recurse --skip "^mailto:"
kill $PREVIEW_PID 2>/dev/null || true
wait $PREVIEW_PID 2>/dev/null || true
trap - EXIT