Skip to content

Fix Chinese translation workflow #85

Fix Chinese translation workflow

Fix Chinese translation workflow #85

name: Translate Notebooks to Chinese
on:
push:
branches:
- main
paths:
- "**/*.ipynb"
- "translate_notebooks.py"
- ".github/workflows/translate-notebooks.yml"
pull_request:
branches:
- main
paths:
- "**/*.ipynb"
- "translate_notebooks.py"
- ".github/workflows/translate-notebooks.yml"
workflow_dispatch:
permissions:
contents: write
jobs:
translate:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install nbformat requests
- name: Translate Notebooks
env:
QWEN_API_KEY: ${{ secrets.QWEN_API_KEY }}
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
QWEN_API_ENDPOINT: ${{ vars.QWEN_API_ENDPOINT }}
QWEN_MODEL: ${{ vars.QWEN_MODEL }}
run: |
python translate_notebooks.py
- name: Commit translated notebooks
if: github.event_name != 'pull_request'
run: |
if [ -z "$(git status --porcelain -- translated-notebooks)" ]; then
echo "No translated notebook changes to commit."
exit 0
fi
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions Bot"
git add translated-notebooks
git commit -m "chore: update Chinese notebook translations"
git push origin HEAD:main