Skip to content

workflow: sync multi-language docs from changed source docs on main#3626

Open
Copilot wants to merge 4 commits into
mainfrom
copilot/add-github-action-for-document-translations
Open

workflow: sync multi-language docs from changed source docs on main#3626
Copilot wants to merge 4 commits into
mainfrom
copilot/add-github-action-for-document-translations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

Docs are maintained in multiple language folders, but updates in one language were not propagated to others. This PR adds an automated sync workflow that detects changed docs on main and updates corresponding files in other locales via model-based translation.

  • Workflow trigger and guardrails

    • Adds .github/workflows/docs-translation-sync.yml.
    • Runs on push to main for docs/src/**/*.md.
    • Skips runs triggered by github-actions[bot] to prevent translation-commit loops.
  • Change detection and locale mapping

    • Diffs ${{ github.event.before }}..${{ github.sha }} to find modified markdown files.
    • Resolves source locale from existing folder layout (de, en, es, fr, id, it, jp, ko-KR, pt-BR, ru, vi-VN, zh-TW, and root as zh-CN).
    • Only targets counterpart files that already exist in other locales.
  • Translation execution

    • Calls GitHub Models endpoint (https://models.inference.ai.azure.com/chat/completions) with gpt-4.1-mini.
    • Uses a markdown-preserving prompt (frontmatter, links, code blocks, inline code, HTML).
    • Adds API failure handling for HTTP/network errors and validates response schema before write.
  • Write-back behavior

    • Updates files only when translated content differs.
    • Preserves trailing newline behavior based on source file.
    • Commits and pushes doc sync changes automatically when there is a real diff.
on:
  push:
    branches: [main]
    paths:
      - docs/src/**/*.md

jobs:
  sync-docs:
    if: github.actor != 'github-actions[bot]'

@lizheming lizheming marked this pull request as ready for review June 1, 2026 03:49
@lizheming lizheming requested a review from Copilot June 1, 2026 03:49
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54d2ef4c28

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +35 to +36
MODEL_ENDPOINT: https://models.inference.ai.azure.com/chat/completions
MODEL_NAME: gpt-4.1-mini
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Switch to the supported GitHub Models API configuration

Every docs push reaches an endpoint that no longer serves GitHub Models requests. GitHub's deprecation notice states that support for https://models.inference.ai.azure.com was removed on October 17, 2025, and the current REST API documentation uses https://models.github.ai/inference/chat/completions with publisher-qualified model IDs such as openai/gpt-4.1. Update both values here, including changing the model to its catalog ID such as openai/gpt-4.1-mini; otherwise the newly added workflow fails before it can synchronize any translation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 帮我根据这个建议修改当前 PR 内容

target_path = render_path(target_locale, relative_path)
if not target_path.exists():
continue
updates[target_path] = (source_locale, target_locale, source_content, relative_path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve locale files that were edited in the triggering push

When one push intentionally updates the same document in multiple locales, each source schedules translations for every other locale and this assignment silently replaces any earlier scheduled value for the same target. This is a real repository workflow: for example, commit 1756c6e edits advanced/contribution.md in the root and every locale directory together. With that kind of push, the loop eventually overwrites the manually maintained documents with model output derived from whichever locale happens to appear last in git diff --name-only, and even the last source locale is overwritten by the preceding source. Exclude targets present in changed_files and define an authoritative source before populating updates.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 帮忙根据建议优化下

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an automated GitHub Actions workflow to synchronize changed Markdown documentation across existing locale folders using GitHub Models translation.

Changes:

  • Adds a push workflow for main doc Markdown changes.
  • Detects changed docs, maps source/target locales, and translates existing counterpart files.
  • Commits updated translations back to the repository when content changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/docs-translation-sync.yml Outdated
Comment on lines +237 to +238
git commit -m "docs: sync docs translations [skip ci]"
git push
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit by adding a workflow_run trigger to docs-deploy.yml. The deploy workflow now also fires when the "Sync translated docs" workflow completes on main, so translated docs are deployed even though the translation commit is pushed via GITHUB_TOKEN (which doesn't trigger other workflows) and carries [skip ci].

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants