Skip to content

Add zh-cn translation sync workflow (Phase 0 Track B)#979

Open
mmcky wants to merge 2 commits into
mainfrom
phase0/sync-translations-zh-cn
Open

Add zh-cn translation sync workflow (Phase 0 Track B)#979
mmcky wants to merge 2 commits into
mainfrom
phase0/sync-translations-zh-cn

Conversation

@mmcky

@mmcky mmcky commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Part of #947. Wires this repo as the English source for QuantEcon/lecture-python.zh-cn: on each merged lecture PR (or a \translate-resync comment) the action translates the changed lectures and opens a PR in the target repo. Copied from lecture-python-intro's proven workflow with only the target-repo changed; pins QuantEcon/action-translation@v0.

Secrets: ANTHROPIC_API_KEY and QUANTECON_SERVICES_PAT are already org-visible to this repo (verified 2026-07-18).

Decision note for merge time: 42 of 121 lectures have no translation yet. Once this workflow is live, a merged source PR touching an untranslated lecture will open a new-translation PR in the target — effectively incremental Phase 2 without a restarted review campaign. If that is not wanted yet, hold this PR until the campaign scoping (see the Track B editor report in project-translation) is settled, or merge and triage new-file PRs as they appear; each arrives as a reviewable PR either way.

🤖 Generated with Claude Code

Wires this repo as the source for QuantEcon/lecture-python.zh-cn: on each
merged lecture PR (or a \translate-resync comment), the action translates
the changed lectures and opens a PR in the target repo.

Copied from lecture-python-intro's proven workflow with only the
target-repo changed. Part of Phase 0 Track B (#947).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 18, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a GitHub Actions workflow to automatically sync (translate) changed lecture content from this English source repository into the QuantEcon/lecture-python.zh-cn target repository when PRs merge (or when manually re-triggered via a \translate-resync comment).

Changes:

  • Introduces a new workflow triggered on merged PRs affecting lecture Markdown / _toc.yml.
  • Adds an issue_comment trigger intended to allow manual resync via \translate-resync.
  • Runs QuantEcon/action-translation in sync mode targeting QuantEcon/lecture-python.zh-cn.

Comment on lines +17 to +19
if: >
(github.event_name == 'pull_request' && github.event.pull_request.merged == true) ||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '\translate-resync'))

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 8abdb57 — the issue_comment path now requires the comment to be on a PR (github.event.issue.pull_request), contain the command, and come from a trusted author (author_association in OWNER/MEMBER/COLLABORATOR). Also being propagated to the upstream template and the sibling source-sync workflows (intro, programming), which share this shape — tracked in action-translation.

with:
fetch-depth: 2

- uses: QuantEcon/action-translation@v0

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.

Declining this one deliberately: floating @v0 is the program's settled pin policy (decision of record 2026-07-18, QuantEcon/project-translation#9). It is the action's own documented convention, and exact pins demonstrably starved repos of needed fixes — v0.17.0's typography fix sat unreachable behind nine exact pins while live syncs kept stripping non-breaking spaces. The 0.x-may-break risk is mitigated where it matters: every sync lands as a PR a human reviews before merge. (Also, latest is v0.20.0, not v0.17.0.)

issue_comment:
types: [created]

jobs:

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 8abdb57 — added job-level permissions: contents: read. The action authenticates with QUANTECON_SERVICES_PAT via its github-token input, so the ambient GITHUB_TOKEN is unused beyond checkout; read-only is sufficient. Also headed for the upstream template.

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-979--sunny-cactus-210e3e.netlify.app

Commit: 8abdb57


Build Info

@mmcky

mmcky commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Pre-merge verification per QuantEcon/project-translation#14 step 3 (2026-07-22):

PinQuantEcon/action-translation@v0 ✅ (floating-tag policy of record; currently resolves to v0.20.0 with the structural-parity guard).

Shape — byte-identical to the proven source-sync template in lecture-python-intro (sync-translations-zh-cn.yml, e2e-verified 2026-07-18 on intro#793 → intro.zh-cn#267), differing only in target-repo. Triggers, \translate-resync comment path, fetch-depth: 2, and both secret wirings match.

Secrets — both org secrets are visible to this repo (verified via the repo's organization-secrets API): ANTHROPIC_API_KEY ✅ and QUANTECON_SERVICES_PAT ✅. The loud-failure risk from the #125 rollout history is cleared.

Target readiness — lecture-python.zh-cn is fully prepared: drift reconciled and merged (#188#193), metadata bootstrap merged (#195), corpus verified at 84 aligned + 37 source-only with zero outdated and zero missing heading-maps, review/rebase workflows live on @v0 + PAT.

Ready to merge. Once in, the first organic lecture merge (or a \translate-resync on a merged PR) serves as the end-to-end verification — the last item before QuantEcon/action-translation#74 closes.

…issions

Copilot review: the issue_comment trigger ran a secrets-bearing job for any
comment containing the command, from any user, on any issue. Now requires a
PR comment from OWNER/MEMBER/COLLABORATOR. Adds permissions: contents: read
since the action authenticates via QUANTECON_SERVICES_PAT, not GITHUB_TOKEN.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.

2 participants