feat: add update-en-docs action #26
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: | |
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 | |
# 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') }} | |
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 }} | |
# 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' |