Skip to content

Reference

The custom action uses GitHub Models to translate markdown files in your repository. It is designed to be used in a GitHub Actions workflow to automatically translate documentation files when they are updated.

.github/workflows/ct.yml
- uses: pelikhan/action-continuous-translation@v0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
lang: fr,es

You can save this file in your .github/workflows/ directory as ct.yml:

.github/workflows/ct.yml
name: Continuous Translation
on:
workflow_dispatch:
# translate when doc files are changed in main
push:
branches:
- main
paths: # update the file paths
- "README.md"
- "docs/src/content/docs/**"
permissions:
contents: write
# allow the action to use the GitHub Models API
models: read
concurrency:
# cancel in-progress jobs for the same workflow and ref
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
continuous_translation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# cache the LLM inference results
- uses: actions/cache@v4
with:
path: .genaiscript/cache/**
key: continuous-translation-${{ github.run_id }}
restore-keys: |
continuous-translation-
# this is the translation action
- uses: pelikhan/action-continuous-translation@v0
continue-on-error: true # don't stop if translation fails, we still need to store the cache
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
lang: fr,es
# commit the generated files
- uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "**.md* translations/**/*.json"
commit_message: "[cai] translated docs"
commit_user_name: "genaiscript"

The pelikhan/action-continuous-translation GitHub action supports the following parameters. All parameters are optional. The default values are shown in the reference below.

with:
lang: fr
source: en
files: README.md
instructions:
instructions_file:
starlight_dir:
starlight_base:
force: false
model_alias: |
translate: github:gpt-4o-mini
debug: false

See Models for more details about other provides like OpenAI, Azure OpenAI, etc.

Type: string
Default: fr

A list of ISO-codes of the target languages separated by colon (,) to which the documentation should be translated to from the source language. See a list of all supported languages in the models.mts file in the repository.

Type: string
Default: en

The ISO-code of the source language the main content is written in.

Type: string
Default: README.md

A list of files to process separated by colons.

Type: string

Extra instructions for the LLM to use when translating.

Type: string

Path to a file containing extra instructions for the LLM to use when translating.

Type: string Default: translations

Folder where the translations will be stored.

Type: string

Root folder of the Astro Starlight documentation. Must be defined if the starlight_base option is defined.

Type: string

Base alias for the Astro Starlight documentation. If you do not define the Astro base option, do not set this option.

Type: boolean
Default: false

Force translation even if the file has already been translated.

Type: boolean
Default: false

Enable debug logging. Read further details under the GenAIScript Logging docs.

Type: string
Example: translate: github:gpt-4o-mini

A mapping of model names to their aliases as a YAML object. This can be used to specify which model to use for a particular translation.

Type: string (secret recommended)
Example: ${{ secrets.GITHUB_TOKEN }}

Your GitHub token with at least models: read permission.

Read further details under the GenAIScript GitHub Models Permissions docs.

You can also use other LLM providers like OpenAI, Azure OpenAI, etc. See Models for more details about other providers.