Sync and Translate Documentation #24
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 | |
on: | |
schedule: | |
- cron: '0 0 * * *' # 每天 UTC 时间午夜运行一次 | |
workflow_dispatch: | |
jobs: | |
sync-and-translate: | |
runs-on: ubuntu-latest | |
steps: | |
- 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 | |
working-directory: userrepo | |
run: git remote add upstream https://github.com/isaac-sim/IsaacLab.git | |
- name: Fetch upstream changes | |
working-directory: userrepo | |
run: git fetch upstream | |
- name: Check for upstream changes | |
id: check-upstream | |
working-directory: userrepo | |
run: | | |
git checkout main | |
git diff HEAD upstream/main > diff.log | |
if [ -s diff.log ]; then | |
echo "changes detected" | |
else | |
echo "no changes" | |
fi | |
- name: Exit if no upstream changes | |
if: steps.check-upstream.outputs.diff == 'no changes' | |
run: echo "No changes detected, exiting." | |
- name: Merge upstream changes while keeping local changes | |
if: steps.check-upstream.outputs.diff == 'changes detected' | |
working-directory: userrepo | |
run: | | |
git merge upstream/main -X ours --allow-unrelated-histories | |
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: 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 setuptools polib==1.2.0 openai==v1.3.6 python-dotenv==1.0.0 pytest==8.2.2 sphinx-intl sphinx-book-theme==1.0.1 myst-parser sphinxcontrib-bibtex==2.5.0 autodocsumm sphinx-copybutton sphinx-icon sphinx_design sphinxemoji numpy matplotlib warp-lang gymnasium | |
- 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: List all files in locales/zh_CN/LC_MESSAGES | |
working-directory: isaaclab/docs | |
run: ls -l locales/zh_CN/LC_MESSAGES | |
- name: Translate using custom script | |
working-directory: isaaclab/docs | |
run: python ../../userrepo/docs/po_translator.py --folder ./locales --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 HTML files to user repo | |
run: | | |
mkdir -p userrepo/temp_html | |
cp -r isaaclab/docs/_build/html/* userrepo/temp_html/ | |
- name: Commit and push changes to gh-pages-zhcn branch | |
working-directory: userrepo | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
git checkout --orphan gh-pages-zhcn | |
git rm -rf . | |
cp -r temp_html/* . | |
git add . | |
git commit -m "Update translated documentation" | |
git push origin gh-pages-zhcn --force | |
- name: Commit and push gettext and po files to main branch | |
working-directory: isaaclab/docs | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
git add -f _build/gettext/* | |
git add -f locales/zh_CN/LC_MESSAGES/*.po | |
git commit -m "Update gettext and po files" | |
git push origin main |