Skip to content

Translate Documentation #191

Translate Documentation

Translate Documentation #191

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'
custom_arguments:
description: 'Custom arguments to pass to the translation package command. e.g., "-t zh-hans"'
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
custom_arguments: ${{ github.event.inputs.custom_arguments }}
pr_branch: ${{ github.event.inputs.pr_branch || 'docs/update-translations' }}
# 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'