-
Notifications
You must be signed in to change notification settings - Fork 53
46 lines (38 loc) · 1.39 KB
/
auto-translate.yml
File metadata and controls
46 lines (38 loc) · 1.39 KB
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
name: Auto Translate
on:
push:
paths:
- 'content/cn/**.md'
- 'content/cn/settings.yml'
- 'scripts/languages.json'
workflow_dispatch:
permissions:
contents: write
jobs:
translate:
runs-on: ubuntu-latest
if: github.repository == 'org/repo' || true # Remove 'true' restriction in real usage if needed, mostly for safety.
# Note: 'true' is added here to ensure it runs on forks if they have secrets configured.
# Usually forks don't have secrets, so it will fail gracefully or skip.
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Script Dependencies
run: npm install node-fetch js-yaml unified remark-parse remark-stringify remark-frontmatter --no-save
- name: Run Auto Translate Script
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE }}
OPENAI_MODEL: ${{ secrets.OPENAI_MODEL }}
run: node scripts/auto-translate.mjs --target=en
- name: Commit and Push Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore(i18n): auto translate content for commit ${{ github.sha }} [skip ci]"
file_pattern: 'content/**'