-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (101 loc) · 3.94 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
121 lines (101 loc) · 3.94 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
name: Deploy Docs
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: pages
cancel-in-progress: false
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
- name: Configure Pages
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
- uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # nightly
with:
toolchain: nightly
- name: Install workspace dependencies
run: npm ci
- name: Run codegen (cargo + rust → ts + truapi build + dts bundle)
run: ./scripts/codegen.sh
- name: Build Rust API docs (HTML)
run: cargo doc -p truapi --no-deps
- name: Install playground dependencies
working-directory: playground
run: yarn install --frozen-lockfile
- name: Cache Next.js build
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: playground/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('playground/yarn.lock') }}-${{ hashFiles('playground/src/**', 'playground/scripts/**', 'playground/public/**', 'playground/next.config.js', 'playground/tsconfig.json', 'playground/package.json') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('playground/yarn.lock') }}-
- name: Build playground (static export)
working-directory: playground
env:
NEXT_PUBLIC_BASE_PATH: /truapi/playground
run: yarn build
- name: Install explorer dependencies
working-directory: explorer
run: npm ci
- name: Build explorer (static export)
working-directory: explorer
env:
EXPLORER_BASE_PATH: /truapi/
run: npm run build
- name: Assemble GitHub Pages site
run: |
rm -rf site
mkdir -p site
# Explorer SPA at the site root.
cp -R explorer/dist/. site/
# GitHub Pages serves the site-root 404.html for every missing path.
# Serving a copy of the SPA index lets React Router resolve explorer
# deep links (e.g. /truapi/v/main/method/foo) on a fresh load.
cp site/index.html site/404.html
# Playground mounted at /playground/ (its Next.js basePath).
mkdir -p site/playground
cp -R playground/out/. site/playground/
# truapi crate's cargo doc mounted at /cargo_doc/ with the crate's
# pages flattened (no /truapi/ prefix). rustdoc HTMLs reference
# static.files via `../../../static.files/`, which from
# /cargo_doc/api/<mod>/ resolves to the site root, so static.files
# must be a sibling of cargo_doc/ (not inside it).
mkdir -p site/cargo_doc
cp -RL target/doc/truapi/. site/cargo_doc/
cp -RL target/doc/static.files site/static.files
touch site/.nojekyll
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: site
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0