Skip to content

Commit 0d70de9

Browse files
committed
release workflow for docs
1 parent 7a7496f commit 0d70de9

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed

.github/workflows/docs.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "docs/**"
8+
- ".github/workflows/docs.yml"
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
test_and_lint:
21+
name: CI Gate (tests + lint)
22+
runs-on: ubuntu-latest
23+
container:
24+
image: rust:1.88.0
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Install Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: "20"
32+
33+
- name: Install pnpm
34+
uses: pnpm/action-setup@v4
35+
with:
36+
version: 10
37+
38+
- name: Install rustfmt and clippy
39+
run: |
40+
rustup component add rustfmt clippy
41+
42+
- name: Get pnpm store directory
43+
id: pnpm-cache
44+
run: |
45+
echo "STORE_PATH=$(pnpm store path)" >> "$GITHUB_OUTPUT"
46+
47+
- name: Cache pnpm dependencies
48+
uses: actions/cache@v4
49+
with:
50+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
51+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
52+
restore-keys: |
53+
${{ runner.os }}-pnpm-
54+
55+
- name: Cache cargo dependencies and build artifacts
56+
uses: actions/cache@v4
57+
with:
58+
path: |
59+
~/.cargo
60+
target/
61+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-cargo-
64+
65+
- name: Install pnpm dependencies
66+
run: pnpm install --frozen-lockfile
67+
68+
- name: Add node_modules/.bin to PATH
69+
run: echo "$PWD/node_modules/.bin" >> "$GITHUB_PATH"
70+
71+
- name: Download cargo dependencies
72+
run: cargo fetch --locked
73+
74+
- name: Check formatting
75+
run: cargo fmt -- --check
76+
77+
- name: Run linting
78+
run: cargo clippy --all-targets --all-features -- -D warnings
79+
80+
- name: Run tests
81+
run: cargo test --all
82+
83+
build:
84+
name: Build Docs
85+
runs-on: ubuntu-latest
86+
needs: test_and_lint
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Setup Node.js
91+
uses: actions/setup-node@v4
92+
with:
93+
node-version: "20"
94+
95+
- name: Setup pnpm
96+
uses: pnpm/action-setup@v4
97+
with:
98+
version: 10
99+
100+
- name: Install root deps (if any)
101+
run: |
102+
pnpm install --frozen-lockfile || pnpm install
103+
104+
- name: Build docs (if present)
105+
run: |
106+
set -e
107+
if [ -f docs/package.json ]; then
108+
cd docs
109+
pnpm install --frozen-lockfile || pnpm install
110+
if pnpm run -s build; then
111+
echo "Docs built with pnpm"
112+
elif npm run build; then
113+
echo "Docs built with npm"
114+
else
115+
echo "Docs build script not found" >&2
116+
exit 1
117+
fi
118+
else
119+
echo "No docs/package.json found; skipping docs build"
120+
mkdir -p build
121+
echo '<html><body><h1>No docs found</h1></body></html>' > build/index.html
122+
fi
123+
124+
- name: Configure Pages
125+
uses: actions/configure-pages@v5
126+
127+
- name: Upload artifact
128+
uses: actions/upload-pages-artifact@v3
129+
with:
130+
path: docs/build
131+
132+
deploy:
133+
name: Deploy Docs
134+
environment:
135+
name: github-pages
136+
url: ${{ steps.deployment.outputs.page_url }}
137+
runs-on: ubuntu-latest
138+
needs: build
139+
steps:
140+
- name: Deploy to GitHub Pages
141+
id: deployment
142+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)