From 95857cae78434cfa0e7ba3308101a1f49052073a Mon Sep 17 00:00:00 2001 From: Lee Stott Date: Sun, 24 Aug 2025 21:41:31 +0100 Subject: [PATCH] Update workflow --- .github/workflows/co-op-translator.yml | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/co-op-translator.yml diff --git a/.github/workflows/co-op-translator.yml b/.github/workflows/co-op-translator.yml new file mode 100644 index 00000000..2313efd7 --- /dev/null +++ b/.github/workflows/co-op-translator.yml @@ -0,0 +1,90 @@ +name: Co-op Translator + +on: + push: + branches: + - main + +jobs: + co-op-translator: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Co-op Translator + run: | + python -m pip install --upgrade pip + pip install co-op-translator + + - name: Run Co-op Translator + env: + PYTHONIOENCODING: utf-8 + # Azure AI Service Credentials + AZURE_AI_SERVICE_API_KEY: ${{ secrets.AZURE_AI_SERVICE_API_KEY }} + AZURE_AI_SERVICE_ENDPOINT: ${{ secrets.AZURE_AI_SERVICE_ENDPOINT }} + + # Azure OpenAI Credentials + 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 Credentials + 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 }} + run: | + # ===================================================================== + # IMPORTANT: Set your target languages here (REQUIRED CONFIGURATION) + # ===================================================================== + # Example: Translate to Spanish, French, German. Add -y to auto-confirm. + # translate -l "all" -y # <--- MODIFY THIS LINE with your desired languages + translate -l "pt es de fa pl hi" -y + # translate -l "zh tw hk fr ja ko" -y + + - name: Authenticate GitHub App + id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.GH_APP_ID }} + private_key: ${{ secrets.GH_APP_PRIVATE_KEY }} + + - name: Create Pull Request with translations + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ steps.generate_token.outputs.token }} + commit-message: "🌐 Update translations via Co-op Translator" + title: "🌐 Update translations via Co-op Translator" + body: | + This PR updates translations for recent changes merged into the `main` branch. + + ### 📋 Summary of Changes + - Translated markdown content has been added under the `translations/` directory + - Translated images (if applicable) have been generated in the `translated_images/` directory + + 🔁 Co-op Translator ensures that changes in links, structure, or inline elements in the original content are automatically reflected in all translated files. + + --- + 🌐 This pull request was automatically generated by [Co-op Translator](https://github.com/Azure/co-op-translator), powered by Azure AI. + + branch: update-translations + base: main + delete-branch: true + add-paths: | + translations/ + translated_images/