-
Notifications
You must be signed in to change notification settings - Fork 85
54 lines (46 loc) · 1.58 KB
/
translate_docs.yml
File metadata and controls
54 lines (46 loc) · 1.58 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
47
48
49
50
51
52
53
54
name: Translate Docs
on:
push:
branches: [main]
paths:
- 'docs/src/en/**'
workflow_dispatch:
# Only one translation run at a time; new pushes cancel in-progress runs.
concurrency:
group: translate-docs
cancel-in-progress: true
jobs:
translate:
runs-on: ubuntu-latest
# Skip commits made by this workflow to avoid loops.
if: "!contains(github.event.head_commit.message, '[skip translate]')"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history so git diff works
token: ${{ secrets.TRAFFIC_ACTION_TOKEN }} # PAT so the push triggers deploy.yml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: pip install anthropic
- name: Run translation
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BEFORE_SHA: ${{ github.event.before }}
AFTER_SHA: ${{ github.sha }}
run: python .github/scripts/translate_docs.py
- name: Commit and push translations
run: |
if [ -z "$(git status --porcelain docs/src/es/)" ]; then
echo "No Spanish doc changes to commit."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add docs/src/es/
git commit -m "Auto-translate Spanish docs [skip translate]"
git pull --rebase origin main
git push