> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI4NzliYTZjZS00OTNhLTQ5NDEtOGQ1My0xOWE5MjMwOGI1OWQiLCJleHAiOjE3NzgyNjM5NDAsImlhdCI6MTc3ODI2MzY0MH0.4T0oXHqNEh8sfNpfSXGOyubYqHtqlitktWwL3dhAD9g
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 协调发布

> 基于 GitHub 仓库发布自动化文档发布。设置工作流程在功能发布时触发自动合并 PR。

Fern Docs 支持基于其他仓库的发布来协调文档发布。这在记录依赖于其他仓库发布的功能时很有用。

这需要两个 GitHub Actions：一个在功能仓库中，一个在文档仓库中。

<Steps>
  <Step title="在功能仓库中设置发布通知">
    将此 GitHub Action 工作流程添加到功能发布的仓库中。当使用指定标签模式创建新发布时，此工作流程将向您的文档仓库发送通知，触发自动合并流程。

    将以下占位符替换为您自己的值：

    * `<GITHUB_ACCESS_TOKEN>`：具有 `repo` 权限的 GitHub 令牌
    * `<ORG>`：包含文档仓库的组织
    * `<DOCS_REPO>`：文档仓库名称
    * `<PRODUCT_RELEASE_TAG>`：产品发布标签

    ```yml title=".github/workflows/notify-docs-repo.yml"
    name: Notify Docs Repo
    on:
      release:
        types: [created]

    jobs:
      notify-docs:
        runs-on: ubuntu-latest
        if: startsWith(github.event.release.tag_name, '<PRODUCT_RELEASE_TAG>@')
        steps:
          - name: Trigger docs repo workflow
            run: |
              curl -f -X POST \
                -H "Accept: application/vnd.github.v3+json" \
                -H "Authorization: token ${{ secrets.<GITHUB_ACCESS_TOKEN> }}" \
                https://api.github.com/repos/<ORG>/<DOCS_REPO>/dispatches \
                -d '{"event_type":"<PRODUCT_RELEASE_TAG>","client_payload":{"version":"${{ github.ref_name }}"}}'
    ```
  </Step>

  <Step title="在文档仓库中配置自动合并">
    将此 GitHub Action 工作流程添加到您的文档仓库中，以在功能发布时自动合并 PR。将 `<PRODUCT_RELEASE_TAG>` 替换为您的产品发布标签。

    ```yml title=".github/workflows/auto-merge-on-release.yml"
    name: Auto-merge on Docs Release
    on:
      repository_dispatch:
        types: [<PRODUCT_RELEASE_TAG>]

    jobs:
      merge-dependent-prs:
        runs-on: ubuntu-latest
        steps:
          - name: Find and merge dependent PRs
            uses: actions/github-script@v7
            with:
              script: |
                const version = context.payload.client_payload.version;
                
                // Find PRs with matching labels
                const { data: prs } = await github.rest.pulls.list({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  state: 'open'
                });
                
                for (const pr of prs) {
                  const labels = pr.labels.map(l => l.name);
                  const hasLatestLabel = labels.includes('depends-on: <PRODUCT_RELEASE_TAG>@latest');
                  const hasVersionLabel = labels.includes(`depends-on: <PRODUCT_RELEASE_TAG>@${version}`);
                  
                  if (hasLatestLabel || hasVersionLabel) {
                    // Check if PR is approved
                    const { data: reviews } = await github.rest.pulls.listReviews({
                      owner: context.repo.owner,
                      repo: context.repo.repo,
                      pull_number: pr.number
                    });
                    
                    const approved = reviews.some(r => r.state === 'APPROVED');
                    
                    if (approved) {
                      await github.rest.pulls.merge({
                        owner: context.repo.owner,
                        repo: context.repo.repo,
                        pull_number: pr.number,
                        merge_method: 'squash'
                      });
                      
                      console.log(`Merged PR #${pr.number}: ${pr.title}`);
                    }
                  }
                }
    ```
  </Step>
</Steps>