-
-
Notifications
You must be signed in to change notification settings - Fork 79
183 lines (156 loc) · 5.44 KB
/
docs.yml
File metadata and controls
183 lines (156 loc) · 5.44 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Workflow for building and deploying versioned VitePress docs to GitHub Pages
name: Deploy VitePress site to Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
# Build current (main) docs
build-current:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- name: Install dependencies
run: npm ci
- name: Generate versions.json
run: |
CURRENT_VERSION=$(grep 'VERSION = "' lib/active_agent/version.rb | sed 's/.*VERSION = "\([^"]*\)".*/\1/')
cat > docs/.vitepress/versions.json << EOF
{
"current": "$CURRENT_VERSION",
"versions": [
{ "version": "$CURRENT_VERSION", "label": "$CURRENT_VERSION (Latest)", "path": "/" },
{ "version": "0.6.3", "label": "0.6.3", "path": "/v0.6.3/docs" }
]
}
EOF
- name: Install test dependencies
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails8.gemfile
run: bundle install
- name: Setup database
env:
RAILS_ENV: test
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails8.gemfile
working-directory: test/dummy
run: |
bundle exec rails db:create
bundle exec rails db:migrate
- name: Generate doc examples from tests
env:
RAILS_ENV: test
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails8.gemfile
ANTHROPIC_API_KEY: ANTHROPIC_API_KEY
OPEN_AI_API_KEY: OPEN_AI_API_KEY
OPEN_ROUTER_API_KEY: OPEN_ROUTER_API_KEY
run: bin/test
- name: Build with VitePress
run: npm run docs:build
- name: Upload current docs artifact
uses: actions/upload-artifact@v7
with:
name: docs-current
path: docs/.vitepress/dist
# Build versioned docs using matrix strategy
# Note: Versioned docs are built from static content in tags (no test generation needed)
build-versioned:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["0.6.3"]
steps:
- name: Checkout version ${{ matrix.version }}
uses: actions/checkout@v6
with:
ref: v${{ matrix.version }}
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Inject base path into existing config
run: |
# Insert base path after the first defineConfig({ line
# This preserves the original sidebar, nav, and all other settings
sed -i "s|export default defineConfig({|export default defineConfig({\n base: '/v${{ matrix.version }}/',\n ignoreDeadLinks: true,|" docs/.vitepress/config.mts
# Show the modified config for debugging
echo "Modified config.mts:"
head -20 docs/.vitepress/config.mts
- name: Build VitePress docs for v${{ matrix.version }}
run: npx vitepress build docs
- name: Fix internal links for versioned docs
run: |
# Rewrite internal absolute links to include the version prefix
# This fixes links in markdown content that use absolute paths like /docs/...
find docs/.vitepress/dist -name "*.html" -exec sed -i \
-e 's|href="/docs/|href="/v${{ matrix.version }}/docs/|g' \
-e 's|href="/activeagent.png"|href="/v${{ matrix.version }}/activeagent.png"|g' \
{} \;
echo "Fixed internal links for v${{ matrix.version }}"
- name: Upload versioned docs artifact
uses: actions/upload-artifact@v7
with:
name: docs-v${{ matrix.version }}
path: docs/.vitepress/dist
# Combine all docs and deploy
deploy:
needs: [build-current, build-versioned]
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download all docs artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: Combine docs into single directory
run: |
mkdir -p dist
# Move current docs to root
cp -r artifacts/docs-current/* dist/
# Move versioned docs to their subdirectories
for dir in artifacts/docs-v*/; do
version=$(basename "$dir" | sed 's/docs-//')
mkdir -p "dist/$version"
cp -r "$dir"* "dist/$version/"
done
echo "Combined docs structure:"
ls -la dist/
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload combined artifact
uses: actions/upload-pages-artifact@v4
with:
path: dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4