Tutorial 03: multi-agent orchestration with Reflow + Ollama (Python) #11
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
| # Build the mdBook in docs/ and deploy it to GitHub Pages. | |
| # | |
| # Triggers | |
| # -------- | |
| # - Push to `main` that touches docs, the example HTMLs, the wasm | |
| # runtime crate, the browser shim, or this workflow. | |
| # - Manual workflow_dispatch — useful for ad-hoc rebuilds. | |
| # | |
| # Live demo embeds | |
| # ---------------- | |
| # Each browser tutorial in `docs/tutorials/real-world/` ships a | |
| # runnable HTML at `sdk/node/examples/tutorial-XX-name/`. The build: | |
| # 1. compiles `crates/reflow_rt_wasm` to wasm32 via wasm-pack | |
| # 2. runs `mdbook build` | |
| # 3. copies every example folder + the browser shim + the freshly | |
| # built wasm into `book/embeds/`, so iframe `src` paths resolve | |
| # and the demos run end-to-end on Pages without any external | |
| # CDN dependency | |
| # | |
| # One-time setup on github.com | |
| # ---------------------------- | |
| # Repo Settings → Pages → "Build and deployment" → Source: GitHub Actions. | |
| # Without that toggle, the deploy job errors with "Get Pages site failed". | |
| name: publish-docs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'docs/**' | |
| - 'book.toml' | |
| - 'sdk/node/examples/tutorial-*-*/**' | |
| - 'sdk/node/reflow.browser.mjs' | |
| - 'crates/reflow_rt_wasm/**' | |
| - 'crates/reflow_actor/**' | |
| - 'crates/reflow_network/**' | |
| - 'crates/reflow_components/**' | |
| - 'crates/reflow_pack_loader/**' | |
| - 'crates/reflow_graph/**' | |
| - 'crates/reflow_tracing_protocol/**' | |
| - '.github/workflows/publish-docs.yml' | |
| workflow_dispatch: | |
| # Required for actions/deploy-pages to mint an OIDC token + push to | |
| # the Pages environment. | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Single in-flight deploy at a time. If a newer commit lands while a | |
| # build is mid-flight, cancel the older one — the latest main always | |
| # wins. | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: build mdbook + tutorial embeds | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain (with wasm32 target) | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Cache cargo + wasm build | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: docs-wasm | |
| # Constrain to the wasm artifacts the docs build needs. | |
| # Native targets are noise here. | |
| workspaces: | | |
| . -> target | |
| - name: Install wasm-pack | |
| run: | | |
| curl -sSfL https://rustwasm.github.io/wasm-pack/installer/init.sh | sh | |
| - name: Build reflow_rt_wasm bundle | |
| # Output lands at sdk/node/wasm/, same place the local dev | |
| # server uses. The embeds copy step picks it up from there. | |
| run: | | |
| wasm-pack build crates/reflow_rt_wasm \ | |
| --target web \ | |
| --out-dir ../../sdk/node/wasm | |
| - name: Install mdBook | |
| uses: peaceiris/actions-mdbook@v2 | |
| with: | |
| # Pin a stable version. Bump as needed; mdBook respects | |
| # backward compatibility on the SUMMARY.md / preprocessor | |
| # surface, so this is mostly cosmetic. | |
| mdbook-version: '0.4.40' | |
| - name: Install mdbook-mermaid | |
| # Pin to 0.14.0 — newer versions are built against mdbook | |
| # 0.4.50+ and reject input from the 0.4.40 we use here. | |
| run: cargo install --version 0.14.0 mdbook-mermaid | |
| - name: Build site | |
| run: mdbook build | |
| - name: Bundle live demo embeds | |
| # Layout under book/embeds/: | |
| # reflow.browser.mjs — the shim | |
| # wasm/ — wasm bundle + JS glue | |
| # tutorial-XX-name/ — example HTML + README | |
| # | |
| # Each example HTML imports the shim via `../../reflow.browser.mjs`, | |
| # so we need the shim two levels up from the example folder. | |
| # Mirroring sdk/node's layout makes that resolve naturally: | |
| # book/embeds/tutorial-XX/ → ../ = book/embeds/ → ../ = book/. | |
| # We re-anchor by placing the shim and wasm/ sibling to the | |
| # tutorial folders, and patching the import path to `../reflow.browser.mjs`. | |
| run: | | |
| set -eux | |
| mkdir -p book/embeds | |
| cp sdk/node/reflow.browser.mjs book/embeds/reflow.browser.mjs | |
| cp -R sdk/node/wasm book/embeds/wasm | |
| for src in sdk/node/examples/tutorial-*-*/; do | |
| name=$(basename "$src") | |
| cp -R "$src" "book/embeds/$name" | |
| # Rewrite `../../reflow.browser.mjs` (from the | |
| # sdk/node/examples/<name>/ layout) to `../reflow.browser.mjs` | |
| # for the book/embeds/<name>/ layout. | |
| sed -i 's|"\.\./\.\./reflow\.browser\.mjs"|"../reflow.browser.mjs"|g' \ | |
| "book/embeds/$name/index.html" | |
| done | |
| - name: Configure Pages | |
| uses: actions/configure-pages@v5 | |
| - uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: book | |
| deploy: | |
| name: deploy to github pages | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - uses: actions/deploy-pages@v4 | |
| id: deployment |