Skip to content

Commit 8989ffa

Browse files
committed
add workflows for ai translations
translate-changed.yml and translate-everything.yml
1 parent 9caca4b commit 8989ffa

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on:
2+
workflow_dispatch:
3+
workflow_call:
4+
5+
concurrency:
6+
group: translate-changed
7+
cancel-in-progress: true
8+
9+
jobs:
10+
translate-changed:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: cd
15+
run: |
16+
cd i18n
17+
- name: Use Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: yarn
22+
- name: Fetch Yarn Dependencies
23+
run: |
24+
yarn install
25+
- name: Clone translated_xmls
26+
run: |
27+
git clone -b translated_xmls https://github.com/source-academy/sicp.git translation_output
28+
- name: Get Changed Files
29+
id: changed-files
30+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46
31+
with:
32+
files: |
33+
xml/**.xml
34+
- name: Create .env
35+
run: |
36+
touch .env
37+
echo API_MODEL=gpt-4.1-mini >> .env
38+
echo API_KEY=${{ secrets.OPENAI_KEY }} >> .env
39+
# echo API_KEY=${{ secrets.OPENAI_KEY2 }} >> .env
40+
- name: Translate Changed Files
41+
if: steps.changed-files.outputs.anychanged == 'true'
42+
env:
43+
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
44+
run: |
45+
npx tsx index.ts "${CHANGED_FILES[@]}"
46+
- name: Deploy
47+
uses: peaceiris/actions-gh-pages@v4
48+
with:
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
publish_dir: ./translation_output
51+
force_orphan: false # leave the possibility for direct modification on translated xmls
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
workflow_dispatch:
3+
worflow_call:
4+
5+
concurrency:
6+
group: translate-everything
7+
cancel-in-progress: true
8+
9+
jobs:
10+
translate-everything:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: cd
15+
run: |
16+
cd i18n
17+
- name: Use Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: yarn
22+
- name: Fetch Yarn Dependencies
23+
run: |
24+
yarn install
25+
- name: Create .env
26+
run: |
27+
touch .env
28+
echo API_MODEL=gpt-4.1-mini >> .env
29+
echo API_KEY=${{ secrets.OPENAI_KEY }} >> .env
30+
# echo API_KEY=${{ secrets.OPENAI_KEY2 }} >> .env
31+
- name: Run Translation
32+
run: |
33+
npx tsx index.ts
34+
- name: Deploy
35+
uses: peaceiris/actions-gh-pages@v4
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
publish_dir: ./translation_output
39+
force_orphan: false # leave the possiblity for direct modification on translated xmls

0 commit comments

Comments
 (0)