|
| 1 | +# Rebase Translation PRs |
| 2 | +# |
| 3 | +# Install this workflow in the TARGET (translated) repository. |
| 4 | +# When a translation PR is merged, this workflow automatically rebases the |
| 5 | +# other open translation PRs against the updated main branch. It covers both |
| 6 | +# kinds this tool creates: `translation-sync-*` branches from the Action's sync |
| 7 | +# mode, and `resync/*` branches from the CLI's `translate forward --github`. |
| 8 | +# |
| 9 | +# This eliminates merge conflicts caused by multiple upstream PRs |
| 10 | +# modifying the same files. See: https://github.com/QuantEcon/action-translation/issues/63 |
| 11 | +# |
| 12 | +# Place this file at: .github/workflows/rebase-translations.yml |
| 13 | + |
| 14 | +name: Rebase Translation PRs |
| 15 | + |
| 16 | +on: |
| 17 | + pull_request: |
| 18 | + types: [closed] |
| 19 | + |
| 20 | +jobs: |
| 21 | + rebase: |
| 22 | + # Only run when a translation PR is merged. Both prefixes must be listed: |
| 23 | + # sync mode creates `translation-sync-*`, while the CLI's `translate forward --github` |
| 24 | + # creates `resync/*`, and a wave of resync PRs goes stale the same way. |
| 25 | + # Keep this in step with `isTranslationBranch` in the action's src/branch-naming.ts |
| 26 | + # — this `if` decides whether the job runs, that predicate decides which open PRs |
| 27 | + # it then rebases, so a prefix matching only one of them is a no-op run. |
| 28 | + # The head-repo check is belt-and-braces: fork PRs never receive secrets, so |
| 29 | + # the PAT is not exposed either way — but a merged fork PR whose branch happens |
| 30 | + # to match a prefix would otherwise start this job with an empty token and fail |
| 31 | + # red. Same-repo branches matching these prefixes only come from the tooling. |
| 32 | + if: > |
| 33 | + github.event.pull_request.merged == true && |
| 34 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 35 | + (startsWith(github.event.pull_request.head.ref, 'translation-sync-') || |
| 36 | + startsWith(github.event.pull_request.head.ref, 'resync/')) |
| 37 | + runs-on: ubuntu-latest |
| 38 | + |
| 39 | + permissions: |
| 40 | + contents: write |
| 41 | + pull-requests: write |
| 42 | + |
| 43 | + # Prevent concurrent rebases from overlapping |
| 44 | + concurrency: |
| 45 | + group: rebase-translations |
| 46 | + cancel-in-progress: false |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Rebase open translation PRs |
| 50 | + uses: QuantEcon/action-translation@v0 |
| 51 | + with: |
| 52 | + mode: rebase |
| 53 | + anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 54 | + # Commits pushed with the default GITHUB_TOKEN do not trigger workflows |
| 55 | + # (GitHub's recursion guard), so rebased/refreshed branches will get their |
| 56 | + # new commit but NO CI runs on it. If checks must re-run — and with |
| 57 | + # required checks a run-less head blocks merging — pass a PAT or App |
| 58 | + # token here instead, as the sync workflows do. |
| 59 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + # Uncomment during a drift-recovery wave. `forward` opens one PR per lecture, |
| 61 | + # so siblings never share a file and none of them are conflict-rebased — but |
| 62 | + # every merge still leaves their checks stale. This refreshes them against the |
| 63 | + # new base without re-translating. Off by default: mid-wave it touches every |
| 64 | + # other open PR on every merge. See action-translation#123. |
| 65 | + # rebase-stale-siblings: 'true' |
0 commit comments