Updating agents file #187
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 dummy app dependencies | |
| working-directory: test/dummy | |
| run: bundle install | |
| - name: Setup database | |
| env: | |
| RAILS_ENV: test | |
| RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
| 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 | |
| RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
| 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@v5 | |
| 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@v5 | |
| 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@v6 | |
| 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 |