-
Notifications
You must be signed in to change notification settings - Fork 7
118 lines (100 loc) · 3.67 KB
/
i18n.yml
File metadata and controls
118 lines (100 loc) · 3.67 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
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
name: Auto-translate Documentation
on:
push:
branches: [main]
paths:
- '**.mdx'
- 'docs.json'
- 'i18n.json'
- 'openapi/**/*.yaml'
- '.github/workflows/i18n.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
translate:
runs-on: ubuntu-latest
# Skip if this is a translation merge commit
if: ${{ !contains(github.event.head_commit.message, 'Auto-update translations and sitemap') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Generate ParamField sections from OpenAPI specs
run: npm run generate:params
- name: Load environment variables
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> $GITHUB_ENV
- name: Run translation
run: npm run i18n
- name: Generate sitemap
run: npm run sitemap
- name: Check for changes
id: changes
run: |
git add -A
if git diff --cached --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changes detected:"
git diff --cached --name-only
fi
- name: Close old translation PRs
if: steps.changes.outputs.changes == 'true'
uses: actions/github-script@v7
with:
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:auto-translations`
});
for (const pr of prs) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
state: 'closed'
});
console.log(`Closed old translation PR #${pr.number}`);
}
- name: Create Pull Request
if: steps.changes.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Auto-update translations and sitemap"
title: "Auto-update translations and sitemap"
body: |
This PR contains automatically generated translations and updated sitemap with hreflang tags.
**Changes:**
- Updated Chinese documentation files in `/zh/` directory
- Updated translation lock file (`i18n.lock`)
- Regenerated sitemap with hreflang tags for SEO (`sitemap.xml`)
**Triggered by:** ${{ github.event.head_commit.message }}
**Commit:** ${{ github.event.head_commit.id }}
**Timestamp:** ${{ github.event.head_commit.timestamp }}
---
This PR was automatically created by the i18n workflow and supersedes any previous translation PRs.
**Note:** `robots.txt` is a static file and doesn't need updates.
branch: auto-translations
delete-branch: true
reviewers: guneysol
add-paths: |
api-reference/
zh/
i18n.lock
sitemap.xml
docs.json