From d5cf6340897e3cff9030351ed9c58992add3ab94 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Fri, 25 Apr 2025 08:31:37 +0900 Subject: [PATCH 1/3] Add a new GH Actions job to automatically update translated document pages --- .github/workflows/update-docs.yml | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/update-docs.yml diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml new file mode 100644 index 000000000..0e682685c --- /dev/null +++ b/.github/workflows/update-docs.yml @@ -0,0 +1,47 @@ +name: "Update Translated Docs" + +# This GitHub Actions job automates the process of updating all translated document pages. Please note the following: +# 1. The translation results may vary each time; some differences in detail are expected. +# 2. When you add a new page to the left-hand menu, **make sure to manually update mkdocs.yml** to include the new item. +# 3. If you switch to a different LLM (for example, from o3 to a newer model), be sure to conduct thorough testing before making the switch. + +on: + push: + branches: + - main + paths: + - 'docs/**' + - mkdocs.yml + +jobs: + update-docs: + name: Build and Push Translated Docs + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + - name: Install dependencies + run: make sync + - name: Build full docs + run: make build-full-docs + + - name: Commit and push changes + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + if [ -n "$(git status --porcelain)" ]; then + git commit -m "Update all translated document pages" + git push + else + echo "No changes to commit" + fi From 00d881d479b8bc4c74d27e896c7018f058ad1f0f Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Mon, 28 Apr 2025 16:48:45 +0900 Subject: [PATCH 2/3] Do git commit only for docs/ files --- .github/workflows/update-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index 0e682685c..4a875fdc4 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -38,7 +38,7 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add . + git add docs/ if [ -n "$(git status --porcelain)" ]; then git commit -m "Update all translated document pages" git push From 9a3719cfe8178770a4243fa4010bde804c04e917 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Thu, 17 Jul 2025 07:41:33 +0900 Subject: [PATCH 3/3] Rename env --- .github/workflows/update-docs.yml | 2 +- docs/scripts/translate_docs.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index 4a875fdc4..fb7ad61e6 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + PROD_OPENAI_API_KEY: ${{ secrets.PROD_OPENAI_API_KEY }} steps: - name: Checkout repository uses: actions/checkout@v3 diff --git a/docs/scripts/translate_docs.py b/docs/scripts/translate_docs.py index ac40b6fa8..a337a90ef 100644 --- a/docs/scripts/translate_docs.py +++ b/docs/scripts/translate_docs.py @@ -30,7 +30,8 @@ } # Initialize OpenAI client -openai_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) +api_key = os.getenv("PROD_OPENAI_API_KEY") or os.getenv("OPENAI_API_KEY") +openai_client = OpenAI(api_key=api_key) # Define dictionaries for translation control do_not_translate = [