Skip to content

GitHub Actions

Use GitHub Actions when you want a repository to translate changed documentation automatically and open a pull request with the generated outputs.

Most repositories should use the standard GITHUB_TOKEN setup. Use the GitHub App setup only when your organization restricts the default token permissions or requires app-based authentication.

Prerequisites

Before creating the workflow, configure the AI service secrets your translation run needs.

Text translation requires 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

Image translation additionally requires 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 this setup for most public and private repositories.

Step 1: Add Repository Secrets

In your target repository, open Settings > Secrets and variables > Actions, then add the provider secrets your workflow will use.

Select Actions secrets

Step 2: Enable Workflow Permissions

Open Settings > Actions > General.

Under Workflow permissions:

  1. Select 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 your project needs. For large repositories, add a paths: filter under on: so the workflow only runs when documentation changes.

GitHub App Setup

Use this setup when GITHUB_TOKEN cannot create commits or pull requests in your organization.

Step 1: Create or Install a GitHub App

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

Record:

  • App ID
  • Private key contents

Store them as repository secrets:

  • GH_APP_ID
  • GH_APP_PRIVATE_KEY

Step 2: Generate an App Token

Use the same workflow as 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 have a maximum job duration. Large repositories or many target languages can exceed that limit.

For large 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 makes hosted runners unreliable.

Review in CI

Use co-op-review when a pull request should 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 is a beta deterministic review command. Its checks and output schema may evolve, but it is designed to be safe for CI because it does not write files or call model providers.