Auto PR (Sync & Translate) #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto PR (Sync & Translate) | |
| on: | |
| schedule: | |
| - cron: "17 3 * * 1" # Weekly on Monday at 03:17 UTC | |
| workflow_dispatch: | |
| inputs: | |
| skip_translate_gate: | |
| description: "翻译失败时仍继续" | |
| type: boolean | |
| default: false | |
| create_pr: | |
| description: "创建 PR(取消不创建,方便调试)" | |
| type: boolean | |
| default: true | |
| translate_provider: | |
| description: "AI CLI used by the translation stage" | |
| type: choice | |
| options: | |
| - copilot | |
| - claude | |
| default: copilot | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| concurrency: | |
| group: autopr-sync | |
| cancel-in-progress: false | |
| env: | |
| UPSTREAM_REPO: vuejs/docs | |
| UPSTREAM_BRANCH: upstream | |
| SYNC_BRANCH: sync | |
| TARGET_BRANCH: main | |
| TRANSLATE_PROVIDER: ${{ github.event.inputs.translate_provider || 'copilot' }} | |
| SKIP_TRANSLATE_GATE: ${{ github.event.inputs.skip_translate_gate || 'false' }} | |
| CREATE_PR: ${{ github.event.inputs.create_pr || 'true' }} | |
| jobs: | |
| sync-translate-submit: | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref_name }} | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Install AI CLI (workflow_dispatch only) | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| if [ "$TRANSLATE_PROVIDER" = "copilot" ]; then | |
| bun install -g @github/copilot | |
| elif [ "$TRANSLATE_PROVIDER" = "claude" ]; then | |
| bun install -g @anthropic-ai/claude-code | |
| fi | |
| - name: Detect upstream changes (schedule only) | |
| if: github.event_name == 'schedule' | |
| run: bun .github/scripts/auto-pr/src/detect-changes.js | |
| - name: Prepare before AI translation | |
| if: github.event_name == 'workflow_dispatch' | |
| run: bun .github/scripts/auto-pr/bin/stage.js prepare | |
| - name: Translate with AI | |
| if: github.event_name == 'workflow_dispatch' | |
| run: bun .github/scripts/auto-pr/bin/stage.js translate | |
| - name: Submit sync PR | |
| if: github.event_name == 'workflow_dispatch' | |
| run: bun .github/scripts/auto-pr/bin/stage.js submit |