AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Configuring `mintlify/multirepo-action` to Synchronize API Docs Across Distributed Repositories

蔡伯威 · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

When engineering organizations scale beyond a single monolithic codebase into dozens of distributed microservices and multi-language client SDKs (such as Python, TypeScript, Go, and Java), maintaining technical documentation becomes an acute operational bottleneck. Forcing engineers to submit secondary pull requests into a separate central documentation repository causes documentation rot, API drifts, and delayed release cycles. Conversely, letting each repository host and deploy its own isolated documentation leads to fragmented developer portals, broken navigation, and disjointed brand experiences.

The official mintlify/multirepo-action bridges this divide. It implements an automated GitOps aggregation pipeline where development teams write docs and generate OpenAPI contracts alongside their source code, while a central documentation portal automatically ingests, rewrites, and publishes them into a unified Mintlify site.

At 365Finds, our research indicates that attempting to manage multi-service documentation via Git submodules or custom shell scripts introduces brittle CI failures and merge conflicts. Using mintlify/multirepo-action provides a production-grade, declarative sync pipeline. Here is how engineering teams configure and operate this architecture safely at scale.


1. Architectural Topology: Central Hub vs. Distributed Sources

The multi-repository documentation architecture separates content ownership from presentation governance:

Distributed Child Repositories                  Central Documentation Hub
┌───────────────────────────┐                  ┌───────────────────────────────────────────────┐
│ acme/service-auth         │                  │ acme/docs-hub                                 │
│  ├── src/                 │                  │  ├── .github/mintlify-multirepo.yml           │
│  ├── docs/ (MDX guides)   │───[Sparse Clone]─┼─▶├── api/auth/ (MDX + openapi.json)           │
│  └── openapi.json         │                  │  ├── api/billing/ (MDX + openapi.json)        │
├───────────────────────────┤                  │  ├── sdks/typescript/ (Quickstarts)           │
│ acme/service-billing      │                  │  ├── docs.base.json (Navigation Blueprint)    │
│  ├── docs/                │───[Sparse Clone]─┼─▶├── docs.json (Generated Live Config)        │
│  └── openapi.json         │                  │  └── .mintlify-multirepo.json (Commit State)  │
├───────────────────────────┤                  │                       │                       │
│ acme/sdk-typescript       │                  │                       │ [Mintlify Deploy]     │
│  └── docs/                │───[Sparse Clone]─┘                       ▼                       ▼
└───────────────────────────┘                             Unified Developer Portal (docs.acme.com)

Core Concepts


2. Step-by-Step Implementation Guide

Step 1: Define the Navigation Blueprint (docs.base.json)

In the root of your central documentation repository, rename your existing docs.json to docs.base.json. This file acts as the compile-time template for your navigation hierarchy.

Insert sourceRef directives wherever a child repository's navigation tree should be mounted:

{
  "$schema": "https://mintlify.com/docs.json",
  "name": "Acme Platform Docs",
  "theme": "mint",
  "colors": {
    "primary": "#059669",
    "light": "#34D399",
    "dark": "#065F46"
  },
  "navigation": {
    "tabs": [
      {
        "tab": "Guides",
        "pages": [
          "index",
          "quickstart",
          "architecture/overview"
        ]
      },
      {
        "tab": "Authentication API",
        "pages": [
          {
            "sourceRef": "acme/service-auth"
          }
        ]
      },
      {
        "tab": "Billing API",
        "pages": [
          {
            "sourceRef": "acme/service-billing"
          }
        ]
      },
      {
        "tab": "Client SDKs",
        "groups": [
          {
            "group": "TypeScript SDK",
            "pages": [
              {
                "sourceRef": "acme/sdk-typescript"
              }
            ]
          }
        ]
      }
    ]
  }
}

How sourceRef Resolves


Step 2: Configure Synchronization Sources (.github/mintlify-multirepo.yml)

Create .github/mintlify-multirepo.yml in the parent repository. This file declares the mapping between remote Git repositories and local destination directories:

base: docs.base.json
output: docs.json

sources:
  - repo: acme/service-auth
    path: docs
    destination: api/auth
    name: Authentication API
    exclude:
      - README.md
      - "internal/**"

  - repo: acme/service-billing
    path: docs
    destination: api/billing
    name: Billing API
    ref: main

  - repo: acme/sdk-typescript
    path: docs
    destination: sdks/typescript
    name: TypeScript SDK
    exclude:
      - "drafts/**"
      - "*.tmp.md"

Key Source Parameters

ParameterTypeDefaultDescription
repoStringRequiredGitHub repository slug (owner/repo)
pathString.Directory in the child repository containing docs and OpenAPI specs
destinationStringRequiredTarget directory in the parent repository and URL prefix path
refStringDefault branchGit branch, tag, or specific commit SHA to clone
nameStringChild repo nameNavigation label used when appending unmapped sources
excludeList[]Glob patterns of files to ignore during sync
rewriteLinksBooleantrueAutomatically rewrites root-relative URLs, assets, and snippet paths

Step 3: Configure Authentication via GitHub App

When child repositories are private, authenticating CI actions across organization repositories is a common failure point.

[!IMPORTANT] 365Finds Recommendation: Avoid using Personal Access Tokens (PATs) for multirepo CI pipelines. PATs are bound to individual developer accounts, creating a single point of failure when employees depart, and they cannot be scoped cleanly. We strongly advise creating a dedicated internal GitHub App and generating ephemeral installation tokens on the fly.

  1. Create an internal GitHub App in your GitHub Organization (Settings → Developer Settings → GitHub Apps).
  2. Grant the app Repository permissions → Contents: Read across all target child repositories.
  3. Grant Contents: Write and Pull requests: Write on the central documentation repository.
  4. Install the app into your organization and save its App ID as an Actions variable (DOCS_APP_ID) and its Private Key as a secret (DOCS_APP_PRIVATE_KEY) in the parent documentation repository.

Step 4: Build the Parent Aggregation Pipeline (.github/workflows/aggregate-docs.yml)

In your parent repository, set up the aggregation workflow:

name: Aggregate Multirepo Docs

on:
  workflow_dispatch:
  schedule:
    - cron: "0 * * * *" # Hourly fallback sync
  repository_dispatch:
    types: [docs-updated] # Event-driven real-time trigger

concurrency:
  group: mintlify-multirepo
  cancel-in-progress: true

permissions:
  contents: write
  pull-requests: write

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Generate GitHub App Token
        id: app-token
        uses: actions/create-github-app-token@v3
        with:
          app-id: ${{ vars.DOCS_APP_ID }}
          private-key: ${{ secrets.DOCS_APP_PRIVATE_KEY }}
          owner: ${{ github.repository_owner }}

      - name: Checkout Parent Repository
        uses: actions/checkout@v4

      - name: Synchronize Documentation Sources
        uses: mintlify/multirepo-action@v1
        with:
          token: ${{ steps.app-token.outputs.token }}
          mode: pull-request # Use 'push' for direct commits or 'pull-request' for staging review
          branch: mintlify-multirepo/sync
          base-branch: main
          commit-message: "chore(docs): synchronize distributed API docs and schemas"
          concurrency: 8

Why Concurrency Protection Matters

Notice the concurrency block:

concurrency:
  group: mintlify-multirepo
  cancel-in-progress: true

In high-velocity engineering organizations, multiple microservices and SDKs may merge pull requests within minutes of each other. Setting a concurrency group with cancel-in-progress: true guarantees that burst events collapse into a single fresh synchronization job, preventing Git push collisions and race conditions.


Step 5: Enable Event-Driven Triggers in Child Repositories

Rather than waiting for the hourly cron job, child repositories can ping the parent repository immediately whenever documentation files change.

Add .github/workflows/notify-docs-hub.yml to each child repository:

name: Notify Central Docs Hub

on:
  push:
    branches:
      - main
    paths:
      - "docs/**"
      - "openapi.json"
      - "openapi.yaml"

jobs:
  dispatch:
    runs-on: ubuntu-latest
    steps:
      - name: Dispatch Event to Parent Repository
        env:
          GH_TOKEN: ${{ secrets.DOCS_DISPATCH_TOKEN }}
        run: |
          gh api repos/${{ github.repository_owner }}/docs-hub/dispatches \
            -f event_type=docs-updated

(Note: DOCS_DISPATCH_TOKEN requires contents: write permissions on the parent repository, which can also be generated from the organization GitHub App).


3. Handling OpenAPI Specifications and MDX Snippets

In modern API platforms, documentation consists of both narrative guides (.mdx) and technical schema references (openapi.json / openapi.yaml). mintlify/multirepo-action handles both seamlessly.

OpenAPI Contract Ingestion

When a child microservice (for example, acme/service-billing) exports its OpenAPI specification into docs/openapi.json:

  1. The action clones docs/openapi.json into api/billing/openapi.json.
  2. The child's local docs.json specifies:
    {
      "navigation": {
        "tabs": [
          {
            "tab": "Billing Reference",
            "openapi": "openapi.json"
          }
        ]
      }
    }
    
  3. During aggregation, the action prefixes the schema path in the compiled docs.json, transforming it into "openapi": "api/billing/openapi.json". Mintlify then dynamically renders the interactive API playground, code sample generators, and parameter tables at docs.acme.com/api/billing.

Asset and Snippet Path Rewriting

When authors write documentation inside a child repository, relative links and snippet imports assume local root paths. The action automatically resolves these boundaries:


4. Comparing Change Delivery Modes: pull-request vs. push

The action provides three operational modes via the mode input parameter:

ModeDeployment FlowConflict HandlingRecommended Use Case
pull-requestCommits changes to mintlify-multirepo/sync and opens or updates a single PRNon-destructive; updates PR branch idempotentlyRegulated enterprises; teams requiring technical writing review, Vale linting, or manual staging checks
pushCommits and pushes directly to base-branch (main)Automatically rebases and retries push if remote moved during syncHigh-velocity microservice platforms with automated OpenAPI contract validation in child repos
noneModifies the working tree without committingLeaves state for subsequent workflow stepsAdvanced CI chains that bundle additional build scripts or custom validations before committing

[!TIP] 365Finds Recommendation: Start with mode: pull-request during initial rollout to observe link rewriting behavior and schema merging. Once stability is proven and automated validation is embedded in child CI pipelines, switch to mode: push for true continuous deployment.


5. Critical Operational Rules & Failure Safeguards

To maintain zero downtime and prevent build breaks in production:

  1. Never Manually Edit Synced Folders in the Parent Repository: Any files inside destination folders (api/auth/, sdks/typescript/, etc.) and the root docs.json are overwritten on every sync run. The action maintains an internal state manifest named .mintlify-multirepo.json. If a child repository is removed from .github/mintlify-multirepo.yml, its corresponding destination folder is cleanly purged on the subsequent run.
  2. Preventing Broken Pull Request Triggers: If you use the default GITHUB_TOKEN to run the action in pull-request mode, GitHub Actions security safeguards will prevent downstream CI workflows (such as Mintlify preview builds or link-checkers) from triggering on the generated PR. Passing a GitHub App token to github-token bypasses this limitation cleanly.
  3. Pre-commit OpenAPI Validation in Child CI: Run mint openapi-check or spectral lint inside each microservice's CI pipeline before merging changes to main. If an invalid OpenAPI spec reaches the parent documentation repository, Mintlify may fail to build the entire portal. Ensure child CI acts as the gatekeeper.

Summary of 365Finds Institutional Judgments

  1. Docs-as-Code Belongs with Source Code: Forcing microservice engineers to context-switch into a centralized documentation monorepo degrades documentation quality. Distributed child repositories with central automated ingestion are mandatory for engineering organizations managing more than five independent services.
  2. Standardize on GitHub App Credentials: Reject personal access tokens for cross-repository workflows. GitHub App installation tokens provide superior audit trails, automatic secret rotation, and unblock downstream CI execution on synchronization pull requests.
  3. Decouple Site Architecture from Commercial Tiers: While Mintlify offers native multi-repo capabilities on its Enterprise plan, running mintlify/multirepo-action via GitHub Actions provides identical unified portal benefits while preserving full GitOps version control, transparent file trees, and local offline preview capabilities (mint dev) across all tiers.

References