Skip to content

Commit 2e1c312

Browse files
MattDHillclaude
andcommitted
deploy to VPS via rsync, add versioned book paths
Replace GitHub Pages deployment with rsync-over-SSH to the VPS. Each book now builds to a versioned path (e.g. start-os/0.4.0.x/) controlled by versions.conf, with nginx handling version inference and legacy redirects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 709658f commit 2e1c312

4 files changed

Lines changed: 112 additions & 28 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 73 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ on:
77

88
permissions:
99
contents: read
10-
pages: write
11-
id-token: write
1210

1311
concurrency:
14-
group: "pages"
12+
group: "deploy"
1513
cancel-in-progress: false
1614

1715
jobs:
18-
build:
16+
build-and-deploy:
1917
runs-on: ubuntu-latest
2018
steps:
2119
- uses: actions/checkout@v4
@@ -37,10 +35,6 @@ jobs:
3735
curl -sSL https://github.com/rust-lang/mdBook/releases/download/${MDBOOK_VERSION}/mdbook-${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz
3836
sudo mv mdbook /usr/local/bin/mdbook
3937
40-
- name: Setup Pages
41-
id: pages
42-
uses: actions/configure-pages@v5
43-
4438
- name: Install mdbook-tabs
4539
run: |
4640
cargo install mdbook-tabs --version 0.3.4
@@ -55,18 +49,75 @@ jobs:
5549
npm ci
5650
npm run generate-llms-txt
5751
58-
- name: Upload artifact
59-
uses: actions/upload-pages-artifact@v3
60-
with:
61-
path: ./docs
52+
- name: Configure SSH
53+
run: |
54+
mkdir -p ~/.ssh
55+
echo "${{ secrets.DOCS_DEPLOY_KEY }}" > ~/.ssh/deploy_key
56+
chmod 600 ~/.ssh/deploy_key
57+
ssh-keyscan -H start9.com >> ~/.ssh/known_hosts
58+
cat >> ~/.ssh/config <<EOF
59+
Host docs-vps
60+
HostName start9.com
61+
User root
62+
IdentityFile ~/.ssh/deploy_key
63+
IdentitiesOnly yes
64+
EOF
6265
63-
deploy:
64-
environment:
65-
name: github-pages
66-
url: ${{ steps.deployment.outputs.page_url }}
67-
runs-on: ubuntu-latest
68-
needs: build
69-
steps:
70-
- name: Deploy to GitHub Pages
71-
id: deployment
72-
uses: actions/deploy-pages@v4
66+
- name: Deploy to VPS
67+
run: |
68+
source versions.conf
69+
DEST="/var/www/html/docs.start9.com"
70+
71+
# Sync each book's versioned directory
72+
rsync -az --delete docs/start-os/$START_OS_VERSION/ docs-vps:$DEST/start-os/$START_OS_VERSION/
73+
rsync -az --delete docs/start-tunnel/$START_TUNNEL_VERSION/ docs-vps:$DEST/start-tunnel/$START_TUNNEL_VERSION/
74+
rsync -az --delete docs/packaging/$PACKAGING_VERSION/ docs-vps:$DEST/packaging/$PACKAGING_VERSION/
75+
76+
# Sync per-book llms.txt into versioned directories (unversioned URLs redirect here)
77+
rsync -az docs/start-os/llms.txt docs/start-os/llms-full.txt docs-vps:$DEST/start-os/$START_OS_VERSION/
78+
rsync -az docs/start-tunnel/llms.txt docs/start-tunnel/llms-full.txt docs-vps:$DEST/start-tunnel/$START_TUNNEL_VERSION/
79+
rsync -az docs/packaging/llms.txt docs/packaging/llms-full.txt docs-vps:$DEST/packaging/$PACKAGING_VERSION/
80+
81+
# Sync landing page and global llms.txt files
82+
rsync -az docs/index.html docs-vps:$DEST/index.html
83+
rsync -az docs/llms.txt docs/llms-full.txt docs-vps:$DEST/
84+
85+
- name: Generate and upload nginx book_versions.conf
86+
run: |
87+
source versions.conf
88+
89+
cat > book_versions.conf <<'NGINX'
90+
# Auto-generated by deploy workflow — do not edit manually
91+
92+
# Extract book name from URI
93+
map $uri $book_name {
94+
default "";
95+
~^/(start-os|start-tunnel|packaging|start-wrt)(/|$) $1;
96+
}
97+
98+
# Latest version per book
99+
map $book_name $latest_book_version {
100+
default "";
101+
NGINX
102+
103+
echo " \"start-os\" \"$START_OS_VERSION\";" >> book_versions.conf
104+
echo " \"start-tunnel\" \"$START_TUNNEL_VERSION\";" >> book_versions.conf
105+
echo " \"packaging\" \"$PACKAGING_VERSION\";" >> book_versions.conf
106+
107+
cat >> book_versions.conf <<'NGINX'
108+
}
109+
110+
# Version resolution: maps book + ?version= param to directory name
111+
NGINX
112+
113+
echo 'map "$book_name:$arg_version" $resolved_book_version {' >> book_versions.conf
114+
echo ' default "";' >> book_versions.conf
115+
echo " \"~^start-os:0\\.4\\.0(\\.|$)\" \"$START_OS_VERSION\";" >> book_versions.conf
116+
echo " \"~^start-tunnel:1\\.0(\\.|$)\" \"$START_TUNNEL_VERSION\";" >> book_versions.conf
117+
echo " \"~^packaging:0\\.4\\.0(\\.|$)\" \"$PACKAGING_VERSION\";" >> book_versions.conf
118+
echo "}" >> book_versions.conf
119+
120+
rsync -az book_versions.conf docs-vps:/etc/nginx/includes/book_versions.conf
121+
122+
- name: Reload nginx
123+
run: ssh docs-vps 'nginx -t && nginx -s reload'

ARCHITECTURE.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,32 @@ The `theme/` directory at repo root is the single source of truth for styling. E
5959
- Theme toggle
6060
- Favicon
6161

62+
## Versioning
63+
64+
Each book is versioned independently via `versions.conf` at repo root:
65+
66+
```bash
67+
START_OS_VERSION="0.4.0.x"
68+
START_TUNNEL_VERSION="1.0.x"
69+
PACKAGING_VERSION="0.4.0.x"
70+
```
71+
72+
Build output goes to `docs/<book>/<version>/` (e.g. `docs/start-os/0.4.0.x/`). The `site-url` is set via environment variable at build time so mdbook generates correct search indexes and canonical URLs for the versioned path.
73+
6274
## Build Pipeline
6375

64-
`build.sh` runs `mdbook build` in each book directory. Output goes to `docs/<book-name>/`. The landing page is copied to `docs/index.html`. CI then generates `llms.txt` and `llms-full.txt` for LLM consumption.
76+
`build.sh` sources `versions.conf` and runs `mdbook build` in each book directory with versioned output paths. The landing page is copied to `docs/index.html`. CI then generates `llms.txt` and `llms-full.txt` for LLM consumption.
77+
78+
## Deployment
79+
80+
Deployment is via GitHub Actions (`.github/workflows/deploy.yml`):
81+
82+
1. Build all books and generate llms.txt
83+
2. rsync each versioned book directory to the VPS at `/var/www/html/docs.start9.com/`
84+
3. Generate and upload `book_versions.conf` (nginx map config) from `versions.conf`
85+
4. Reload nginx
86+
87+
The deploy key is stored as the `DOCS_DEPLOY_KEY` GitHub Actions secret.
6588

6689
## Scripts
6790

@@ -71,4 +94,4 @@ The `theme/` directory at repo root is the single source of truth for styling. E
7194

7295
## Cross-Book Links
7396

74-
mdBook validates links within a single book. Links between books use absolute paths (`/start-tunnel/user-manual/devices.html`) and are not validated at build time. There are only a handful of these.
97+
mdBook validates links within a single book. Links between books use unversioned absolute paths (`/start-tunnel/user-manual/devices.html`) — nginx redirects these to the latest versioned path. These are not validated at build time. There are only a handful of these.

build.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
#!/bin/bash
22
set -e
33

4+
source versions.conf
5+
46
# Clean output
57
rm -rf docs
68
mkdir -p docs
79

8-
# Build books
9-
(cd start-os && mdbook build)
10-
(cd start-tunnel && mdbook build)
11-
(cd packaging && mdbook build)
10+
# Build books with versioned paths
11+
(cd start-os && MDBOOK_OUTPUT__HTML__SITE_URL="/start-os/$START_OS_VERSION/" \
12+
mdbook build -d "../docs/start-os/$START_OS_VERSION")
13+
14+
(cd start-tunnel && MDBOOK_OUTPUT__HTML__SITE_URL="/start-tunnel/$START_TUNNEL_VERSION/" \
15+
mdbook build -d "../docs/start-tunnel/$START_TUNNEL_VERSION")
16+
17+
(cd packaging && MDBOOK_OUTPUT__HTML__SITE_URL="/packaging/$PACKAGING_VERSION/" \
18+
mdbook build -d "../docs/packaging/$PACKAGING_VERSION")
1219

1320
# Landing page
1421
cp landing/index.html docs/index.html

versions.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
START_OS_VERSION="0.4.0.x"
2+
START_TUNNEL_VERSION="1.0.x"
3+
PACKAGING_VERSION="0.4.0.x"

0 commit comments

Comments
 (0)