-
Notifications
You must be signed in to change notification settings - Fork 9
138 lines (112 loc) · 4.19 KB
/
deploy.yml
File metadata and controls
138 lines (112 loc) · 4.19 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
name: Build and deploy docs
on:
push:
branches: ["master"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: "deploy"
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Build docs agent widget
run: |
cd widget
npm ci
npm run build
- name: Install mdBook
run: |
MDBOOK_VERSION='v0.5.2'
curl -sSL https://github.com/rust-lang/mdBook/releases/download/${MDBOOK_VERSION}/mdbook-${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz
sudo mv mdbook /usr/local/bin/mdbook
- name: Install mdbook-tabs
run: |
cargo install mdbook-tabs --version 0.3.4
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Build all books
run: ./build.sh
- name: Generate llms.txt
run: |
cd scripts
npm ci
npm run generate-llms-txt
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DOCS_DEPLOY_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H start9.com >> ~/.ssh/known_hosts
cat >> ~/.ssh/config <<EOF
Host docs-vps
HostName start9.com
User root
IdentityFile ~/.ssh/deploy_key
IdentitiesOnly yes
EOF
- name: Deploy to VPS
run: |
DEST="/var/www/html/docs.start9.com"
# Sync each book's versioned directory + llms.txt
while IFS='=' read -r book version; do
[[ -z "$book" || "$book" =~ ^# ]] && continue
ssh -n docs-vps "mkdir -p $DEST/$book/$version"
rsync -az --delete "docs/$book/$version/" "docs-vps:$DEST/$book/$version/"
rsync -az docs/$book/llms*.txt "docs-vps:$DEST/$book/$version/" 2>/dev/null || true
done < versions.conf
# Sync landing page and global llms.txt files
rsync -az docs/index.html docs-vps:$DEST/index.html
rsync -az docs/llms.txt docs/llms-full.txt docs-vps:$DEST/
- name: Generate and upload nginx book_versions.conf
run: |
cat > book_versions.conf <<'NGINX'
# Auto-generated by deploy workflow — do not edit manually
# Extract first path segment as potential book name
map $uri $book_name {
default "";
~^/([^/]+)(/|$) $1;
}
# Extract path after book name
map $uri $book_rest {
default "";
~^/[^/]+/(.+)$ $1;
}
# Latest version per book
map $book_name $latest_book_version {
default "";
NGINX
while IFS='=' read -r book version; do
[[ -z "$book" || "$book" =~ ^# ]] && continue
echo " \"$book\" \"$version\";" >> book_versions.conf
done < versions.conf
cat >> book_versions.conf <<'NGINX'
}
# Version resolution: maps book + ?version= param to directory name
NGINX
echo 'map "$book_name:$arg_version" $resolved_book_version {' >> book_versions.conf
echo ' default "";' >> book_versions.conf
while IFS='=' read -r book version; do
[[ -z "$book" || "$book" =~ ^# ]] && continue
# e.g. "0.4.0.x" → prefix "0\.4\.0"
prefix="${version%.x}"
prefix_escaped="${prefix//./\\.}"
echo " \"~^${book}:${prefix_escaped}(\\.|$)\" \"$version\";" >> book_versions.conf
done < versions.conf
echo "}" >> book_versions.conf
cat >> book_versions.conf <<'NGINX'
# Target version: use ?version= resolution if available, else latest
map $resolved_book_version $target_version {
"" $latest_book_version;
default $resolved_book_version;
}
NGINX
rsync -az book_versions.conf docs-vps:/etc/nginx/includes/book_versions.conf
- name: Reload nginx
run: ssh docs-vps 'nginx -t && nginx -s reload'