Sync and Translate Documentation #10
Workflow file for this run
This file contains 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: Sync and Translate Documentation | |
permissions: | |
contents: write | |
actions: write | |
on: | |
schedule: | |
- cron: '0 0 * * *' # 每天 UTC 时间午夜运行一次 | |
workflow_dispatch: | |
jobs: | |
sync-and-translate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout user's repo (translate branch) | |
uses: actions/checkout@v2 | |
with: | |
path: userrepo | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: fan-ziqi/IsaacLab | |
ref: translate | |
- name: Copy po_translator.py to temporary path | |
run: cp userrepo/po_translator.py /tmp/po_translator.py | |
- name: Checkout user's repo (main branch) | |
uses: actions/checkout@v2 | |
with: | |
path: userrepo | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: fan-ziqi/IsaacLab | |
ref: main | |
- name: Configure Git user | |
working-directory: userrepo | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
- name: Add upstream repository and sync main | |
working-directory: userrepo | |
run: | | |
git remote add upstream https://github.com/isaac-sim/IsaacLab.git | |
git fetch upstream | |
git checkout main | |
git merge upstream/main -X theirs --allow-unrelated-histories | |
- name: Ignore workflow changes | |
working-directory: userrepo | |
run: | | |
git update-index --assume-unchanged .github/workflows/* | |
- name: Push changes to user's repo | |
working-directory: userrepo | |
run: git push origin main | |
- name: Checkout code from isaac-sim/IsaacLab | |
uses: actions/checkout@v2 | |
with: | |
repository: isaac-sim/IsaacLab | |
ref: main | |
path: isaaclab | |
- name: Copy po_translator.py to docs folder | |
run: cp /tmp/po_translator.py isaaclab/docs/ | |
- name: Check for changes | |
id: changes-check | |
run: | | |
git fetch origin | |
git diff --exit-code origin/main || echo "changes detected" | |
working-directory: isaaclab | |
continue-on-error: true | |
- name: Exit if no changes | |
if: steps.changes-check.outcome == 'success' | |
run: echo "No changes detected, exiting." | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install sphinx sphinx-intl | |
- name: Generate gettext | |
working-directory: isaaclab/docs | |
run: make gettext | |
- name: Update translations | |
working-directory: isaaclab/docs | |
run: sphinx-intl update -p _build/gettext -l zh_CN | |
- name: Translate using custom script | |
working-directory: isaaclab/docs | |
run: python po_translator.py --folder ./locale --lang zh_CN --folder-language | |
- name: Build HTML with translations | |
working-directory: isaaclab/docs | |
run: make -e SPHINXOPTS="-D language='zh_CN'" html | |
- name: Copy generated files to user repo | |
run: | | |
mkdir -p userrepo/docs/zh_CN | |
cp -r isaaclab/docs/_build/html/* userrepo/docs/zh_CN/ | |
- name: Commit and push changes | |
working-directory: userrepo | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
git checkout -b gh-pages-zhcn | |
git add docs/zh_CN | |
git commit -m "Update translated documentation" | |
git push origin gh-pages-zhcn --force |