Skip to content

GitHub Actions

Use GitHub Actions if you want make repository dey translate changed documentation automatically and open pull request with the generated outputs.

Most repositories go use the standard GITHUB_TOKEN setup. Use the GitHub App setup only when your organization don restrict the default token permissions or require app-based authentication.

Wetin you go need

Before you create the workflow, arrange the AI service secrets wey your translation run go need.

Text translation dey require one language model provider:

  • Azure OpenAI: AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_MODEL_NAME, AZURE_OPENAI_CHAT_DEPLOYMENT_NAME, AZURE_OPENAI_API_VERSION
  • OpenAI: OPENAI_API_KEY, OPENAI_CHAT_MODEL_ID, plus optional OPENAI_ORG_ID and OPENAI_BASE_URL

If you wan translate images, you still need Azure AI Vision:

  • AZURE_AI_SERVICE_API_KEY
  • AZURE_AI_SERVICE_ENDPOINT

See Configuration and Azure AI Setup for local configuration details.

Standard Setup

Use dis setup for most public and private repositories.

Step 1: Add Repository Secrets

For the repo wey you dey target, open Settings > Secrets and variables > Actions, then add the provider secrets wey your workflow go use.

Pick Actions secrets

Step 2: Enable Workflow Permissions

Open Settings > Actions > General.

Under Workflow permissions:

  1. Choose Read and write permissions.
  2. Enable Allow GitHub Actions to create and approve pull requests.
  3. Save the setting.

Workflow permission setting

Step 3: Add the Workflow

Create .github/workflows/co-op-translator.yml:

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_API_KEY: ${{ secrets.AZURE_AI_SERVICE_API_KEY }}
          AZURE_AI_SERVICE_ENDPOINT: ${{ secrets.AZURE_AI_SERVICE_ENDPOINT }}
          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 }}
        run: |
          translate -l "es fr de" -y

      - name: Create Pull Request with translations
        uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: "Update translations via Co-op Translator"
          title: "Update translations via Co-op Translator"
          body: |
            This PR updates translations for recent changes to the main branch.

            Generated by Co-op Translator.
          branch: update-translations
          base: main
          labels: translation, automated-pr
          delete-branch: true
          add-paths: |
            translations/
            translated_images/

Change translate -l "es fr de" -y to the target languages and content flags wey your project need. For large repositories, add a paths: filter under on: so the workflow only run when documentation changes.

GitHub App Setup

Use dis setup when GITHUB_TOKEN no fit create commits or pull requests for your organization.

Step 1: Create or Install a GitHub App

Create GitHub App wey get read/write access to Contents and Pull requests, or install the organization-provided app if your organization already maintain one.

Record:

  • App ID
  • Private key contents

Store dem as repository secrets:

  • GH_APP_ID
  • GH_APP_PRIVATE_KEY

Step 2: Generate an App Token

Use the same workflow like the standard setup, but add an app-token step before the pull request step:

      - 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"
          branch: update-translations
          base: main
          delete-branch: true
          add-paths: |
            translations/
            translated_images/

Runner Limits

GitHub-hosted runners get maximum job duration. Large repositories or many target languages fit exceed that limit.

For big translation workloads:

  • Translate fewer languages per run.
  • Use content flags such as -md, -nb, or -img.
  • Use a self-hosted runner when repository size or model latency make hosted runners unreliable.

Review in CI

Use co-op-review when you want make pull request validate generated translations without calling LLM or Vision providers.

      - name: Review translated outputs
        run: |
          co-op-review --changed-from "origin/${{ github.base_ref }}" --format github

co-op-review na beta deterministic review command. Its checks and output schema fit change, but e design make am safe for CI because e no dey write files nor dey call model providers.