Translate Documentation #185
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' | |
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: | |
check-api-key: | |
runs-on: ubuntu-latest | |
# Run when manually triggered OR scheduled OR when the commit message contains "Merge pull request" | |
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || contains(github.event.head_commit.message, 'Merge pull request') }} | |
outputs: | |
api_key_exists: ${{ steps.check-api-key.outputs.api_key_exists }} | |
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." | |
echo "api_key_exists=false" >> $GITHUB_OUTPUT | |
else | |
echo "OPENAI_API_KEY secret is available. Proceeding with translation." | |
echo "api_key_exists=true" >> $GITHUB_OUTPUT | |
fi | |
translate: | |
runs-on: ubuntu-latest | |
needs: check-api-key | |
if: ${{ needs.check-api-key.outputs.api_key_exists == 'true' }} | |
steps: | |
# 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.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: 'main' | |
# 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' |