Translate Documentation #199
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Translate Documentation | |
on: | |
# schedule: | |
# - cron: | |
# '0 20 * * *' # Daily at 20:00 UTC (DeepSeek API off-peak pricing window 16:30-00:30 UTC) | |
# # Pacific Time: 1:00 PM PDT / 12:00 PM PST | |
# # Off-peak window in PT: ~9:30 AM to 5:30 PM PDT / ~8:30 AM to 4:30 PM PST | |
# push: | |
# # Run when merging from official repo to check if translations are outdated | |
# branches: | |
# - main | |
workflow_dispatch: # Allow manual triggering | |
inputs: | |
pr_branch: | |
description: 'Branch name for the pull request' | |
required: false | |
type: string | |
default: 'docs/update-translations' | |
list_only: | |
description: 'Only list file status without updating docs' | |
required: false | |
type: boolean | |
default: false | |
target_language: | |
description: 'Specify the target language code for translation (e.g., "zh-hans", "fr", "es")' | |
required: false | |
type: string | |
pattern: | |
description: 'File pattern to match for updating (e.g., "*.mdx" or "docs/**/*.mdx")' | |
required: false | |
type: string | |
max_files: | |
description: 'Maximum number of files to process in one batch (per language)' | |
required: false | |
type: number | |
concurrency: | |
description: 'Number of concurrent translation tasks' | |
required: false | |
type: number | |
default: 10 | |
model: | |
description: 'DeepSeek model to use' | |
required: false | |
type: choice | |
options: | |
- deepseek-chat | |
- deepseek-reasoner | |
default: deepseek-chat | |
custom_arguments: | |
description: 'Additional custom arguments to pass to the translation package command' | |
required: false | |
type: string | |
# Add permissions needed for creating PRs | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
translate: | |
runs-on: ubuntu-latest | |
steps: | |
# Check if API key is available | |
- name: Check API key | |
id: check-api-key | |
env: | |
API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
run: | | |
if [ -z "$API_KEY" ]; then | |
echo "OPENAI_API_KEY secret is not set. Skipping translation." | |
exit 1 | |
else | |
echo "OPENAI_API_KEY secret is available. Proceeding with translation." | |
fi | |
# Checkout the repository first to access local actions | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for proper timestamp lookup | |
# Use the translate-docs-action | |
- name: Translate documentation | |
uses: ./.github/actions/translate-docs | |
with: | |
# Required inputs | |
api_key: ${{ secrets.OPENAI_API_KEY }} | |
# Optional inputs with their default values shown | |
github_token: ${{ secrets.PAT_TOKEN }} # Use PAT instead of GITHUB_TOKEN | |
pr_branch: ${{ github.event.inputs.pr_branch || 'docs/update-translations' }} | |
# Translation-specific inputs | |
list_only: ${{ github.event.inputs.list_only }} | |
target_language: ${{ github.event.inputs.target_language }} | |
pattern: ${{ github.event.inputs.pattern }} | |
max_files: ${{ github.event.inputs.max_files }} | |
concurrency: ${{ github.event.inputs.concurrency }} | |
model: ${{ github.event.inputs.model }} | |
custom_arguments: ${{ github.event.inputs.custom_arguments }} | |
# translation_command: 'pnpm run translate' | |
base_branch: 'dev' | |
# pr_branch: 'docs/update-translations' | |
# pr_title: 'Update translations' | |
# The following uses YAML pipe syntax for multi-line strings | |
# pr_body: | | |
# This PR updates the documentation translations automatically. | |
# | |
# Generated by the translate workflow. | |
# commit_message: 'docs: update documentation translations' | |
# add_paths: 'apps/docs/content/**' | |
enable_formatting: 'false' | |
# format_command: 'pnpm prettier:write' |