diff --git a/.github/workflows/rebase-translations.yml b/.github/workflows/rebase-translations.yml new file mode 100644 index 0000000..37f5daa --- /dev/null +++ b/.github/workflows/rebase-translations.yml @@ -0,0 +1,41 @@ +# Rebase Translation PRs +# +# Install this workflow in the TARGET (translated) repository. +# When a translation-sync PR is merged, this workflow automatically +# rebases other open translation-sync PRs against the updated main branch. +# +# This eliminates merge conflicts caused by multiple upstream PRs +# modifying the same files. See: https://github.com/QuantEcon/action-translation/issues/63 +# +# Place this file at: .github/workflows/rebase-translations.yml + +name: Rebase Translation PRs + +on: + pull_request: + types: [closed] + +jobs: + rebase: + # Only run when a translation-sync PR is merged + if: > + github.event.pull_request.merged == true && + startsWith(github.event.pull_request.head.ref, 'translation-sync-') + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + # Prevent concurrent rebases from overlapping + concurrency: + group: rebase-translations + cancel-in-progress: false + + steps: + - name: Rebase open translation PRs + uses: QuantEcon/action-translation@v0 + with: + mode: rebase + anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/review-translations.yml b/.github/workflows/review-translations.yml new file mode 100644 index 0000000..c35c566 --- /dev/null +++ b/.github/workflows/review-translations.yml @@ -0,0 +1,49 @@ +# Review Translations — Quality check on translation PRs +# When a PR is opened/updated that carries the 'action-translation' label, +# this workflow runs a quality review and posts a comment. +# +# Mirrors the upstream template in action-translation +# docs/user/tutorials/connect-existing.md — keep it in step with that. +name: Review Translations + +on: + pull_request: + types: [opened, synchronize, labeled, reopened] + +jobs: + review: + # Ignore `labeled` events for every other label: a sync adds its labels in a single + # addLabels call, but GitHub emits one `labeled` event per label, and each would + # otherwise start a full (billed) review of the same diff. + if: > + contains(github.event.pull_request.labels.*.name, 'action-translation') && + (github.event.action != 'labeled' || github.event.label.name == 'action-translation') + runs-on: ubuntu-latest + + # v0.17.0's review dedupe deletes superseded comments, which needs pull-requests: write. + permissions: + contents: read + pull-requests: write + + # One review per PR — supersede an in-flight review instead of running both. + # Job-level (not workflow-level) on purpose: the group is entered only after the `if` + # above has passed, so a `labeled` event for 'automated' skips out without cancelling + # the real review. At workflow level it would cancel first and skip second, leaving none. + concurrency: + group: review-translations-${{ github.event.pull_request.number }} + cancel-in-progress: true + + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 2 + + - uses: QuantEcon/action-translation@v0 + with: + mode: review + source-repo: QuantEcon/lecture-python.myst + source-language: en + target-language: zh-cn + docs-folder: lectures + anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} + github-token: ${{ secrets.GITHUB_TOKEN }}