forked from isaac-sim/IsaacLab
-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (98 loc) · 3.4 KB
/
sync-and-translate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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