Add Translation Polisher workflow for reviewing and enhancing Co-op T… #5
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: Co-op Translator | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "**/*.md" | |
| - "!translations/**" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| translate-markdown: | |
| name: Translate Markdown | |
| runs-on: ubuntu-latest | |
| env: | |
| TRANSLATION_LANGUAGES: "es" | |
| PYTHONIOENCODING: utf-8 | |
| AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} | |
| AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} | |
| AZURE_OPENAI_MODEL_NAME: ${{ secrets.AZURE_OPENAI_MODEL_NAME }} | |
| AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }} | |
| AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }} | |
| OPENAI_CHAT_MODEL_ID: ${{ secrets.OPENAI_CHAT_MODEL_ID }} | |
| OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install Co-op Translator | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install co-op-translator | |
| - name: Translate Markdown | |
| run: | | |
| translate -l "$TRANSLATION_LANGUAGES" -md -y --repo-url "https://github.com/github/copilot-cli-for-beginners.git" | |
| - name: Normalize and review translations | |
| run: | | |
| migrate-links -l "$TRANSLATION_LANGUAGES" -y | |
| node .github/scripts/fix-translated-markdown.js "$TRANSLATION_LANGUAGES" | |
| if command -v co-op-review >/dev/null 2>&1; then | |
| co-op-review -l "$TRANSLATION_LANGUAGES" --format github | |
| else | |
| echo "co-op-review is not available in the installed Co-op Translator package; skipping." | |
| fi | |
| - name: Create pull request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "Update translations via Co-op Translator" | |
| title: "Update translations via Co-op Translator" | |
| body: | | |
| This PR updates Markdown translations generated by Co-op Translator. | |
| Generated content is available in the `translations/` directory. | |
| branch: update-translations | |
| base: main | |
| labels: translation, automated-pr | |
| delete-branch: true | |
| add-paths: | | |
| translations/ |