|
| 1 | +# Review Translations — Quality check on translation PRs |
| 2 | +# When a PR is opened/updated that carries the 'action-translation' label, |
| 3 | +# this workflow runs a quality review and posts a comment. |
| 4 | +# |
| 5 | +# Mirrors the upstream template in action-translation |
| 6 | +# docs/user/tutorials/connect-existing.md — keep it in step with that. |
| 7 | +name: Review Translations |
| 8 | + |
| 9 | +on: |
| 10 | + pull_request: |
| 11 | + types: [opened, synchronize, labeled, reopened] |
| 12 | + |
| 13 | +jobs: |
| 14 | + review: |
| 15 | + # Ignore `labeled` events for every other label: a sync adds its labels in a single |
| 16 | + # addLabels call, but GitHub emits one `labeled` event per label, and each would |
| 17 | + # otherwise start a full (billed) review of the same diff. |
| 18 | + if: > |
| 19 | + contains(github.event.pull_request.labels.*.name, 'action-translation') && |
| 20 | + (github.event.action != 'labeled' || github.event.label.name == 'action-translation') |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + # v0.17.0's review dedupe deletes superseded comments, which needs pull-requests: write. |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + pull-requests: write |
| 27 | + |
| 28 | + # One review per PR — supersede an in-flight review instead of running both. |
| 29 | + # Job-level (not workflow-level) on purpose: the group is entered only after the `if` |
| 30 | + # above has passed, so a `labeled` event for 'automated' skips out without cancelling |
| 31 | + # the real review. At workflow level it would cancel first and skip second, leaving none. |
| 32 | + concurrency: |
| 33 | + group: review-translations-${{ github.event.pull_request.number }} |
| 34 | + cancel-in-progress: true |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v7 |
| 38 | + with: |
| 39 | + fetch-depth: 2 |
| 40 | + |
| 41 | + - uses: QuantEcon/action-translation@v0 |
| 42 | + with: |
| 43 | + mode: review |
| 44 | + source-repo: QuantEcon/lecture-python.myst |
| 45 | + source-language: en |
| 46 | + target-language: zh-cn |
| 47 | + docs-folder: lectures |
| 48 | + anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 49 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments