Skip to content

Commit 541d7bc

Browse files
committed
Add GitHub Actions workflow for translating Python to JavaScript; update paths for output files
1 parent 11339c4 commit 541d7bc

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

.github/workflows/translate2js.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: AI Translate Python to JS
2+
3+
on:
4+
push:
5+
branches:
6+
- wzrdbrain # Matches the deploy workflow branch
7+
paths:
8+
- 'src/wzrdbrain/wzrdbrain.py'
9+
- 'src/wzrdbrain/tricks.json'
10+
- '.github/workflows/translate2js.yml'
11+
workflow_dispatch:
12+
13+
jobs:
14+
translate_and_commit:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.13'
25+
26+
- name: Install dependencies
27+
run: pip install google-genai
28+
29+
- name: Translate Python to JavaScript
30+
run: python scripts/translate.py
31+
env:
32+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
33+
34+
- name: Show first lines of generated file
35+
run: |
36+
echo "Preview of dist/wzrdbrain.src.js:"
37+
head -n 60 dist/wzrdbrain.src.js || true
38+
39+
- name: Upload artifact for review
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: wzrdbrain-js
43+
path: dist/wzrdbrain.src.js
44+
45+
- name: Create Pull Request with generated file
46+
uses: peter-evans/create-pull-request@v6
47+
with:
48+
commit-message: "chore: generate dist/wzrdbrain.js via utils/translate2js.py"
49+
title: "chore: generate wzrdbrain.js via utils/translate2js.py"
50+
body: |
51+
This PR was generated by GitHub Actions using utils/translate2js.py.
52+
- Source: wzrdbrain.py (+ tricks.json if used)
53+
- Output: dist/wzrdbrain.js
54+
branch: chore/translate-wzrdbrain
55+
add-paths: |
56+
dist/wzrdbrain.js

utils/translate2js.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
PROJECT_ROOT = Path(__file__).parent.parent.parent
1212
PYTHON_SOURCE_PATH = PROJECT_ROOT / "src" / "wzrdbrain" / "wzrdbrain.py"
1313
TRICK_DATA_PATH = PROJECT_ROOT / "src" / "wzrdbrain" / "tricks.json"
14-
JS_OUTPUT_PATH = PROJECT_ROOT / "src" / "wzrdbrain" / "wzrdbrain.src.js"
15-
JS_SOURCE_PATH = PROJECT_ROOT / "src" / "wzrdbrain" / "wzrdbrain.base.js"
14+
JS_OUTPUT_PATH = PROJECT_ROOT / "dist" / "wzrdbrain.src.js"
15+
JS_SOURCE_PATH = PROJECT_ROOT / "utils" / "wzrdbrain.base.js"
1616
MODEL_NAME = "gemini-2.5-pro"
1717

1818

File renamed without changes.

0 commit comments

Comments
 (0)