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.
- uses: pelikhan/action-continuous-translation@v0 with: github_token: ${{ secrets.GITHUB_TOKEN }} lang: fr,es
Installation
Section titled “Installation”You can save this file in your .github/workflows/
directory as ct.yml
:
name: Continuous Translationon: 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: readconcurrency: # cancel in-progress jobs for the same workflow and ref group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: truejobs: 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"
Parameters
Section titled “Parameters”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.
source
Section titled “source”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.
instructions
Section titled “instructions”Type: string
Extra instructions for the LLM to use when translating.
instructions_file
Section titled “instructions_file”Type: string
Path to a file containing extra instructions for the LLM to use when translating.
translations_dir
Section titled “translations_dir”Type: string
Default: translations
Folder where the translations will be stored.
starlight_dir
Section titled “starlight_dir”Type: string
Root folder of the Astro Starlight documentation.
Must be defined if the starlight_base
option is defined.
starlight_base
Section titled “starlight_base”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.
model_alias
Section titled “model_alias”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.
github_token
Section titled “github_token”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.
Other LLM providers
Section titled “Other LLM providers”You can also use other LLM providers like OpenAI, Azure OpenAI, etc. See Models for more details about other providers.