Skip to content

Commit 14d2266

Browse files
committed
feat: add translations pipeline
1 parent 484ddb8 commit 14d2266

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/translation.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Check Translation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- gh-pages
7+
paths:
8+
- 'en/**'
9+
- 'es/**'
10+
- 'fr/**'
11+
- 'it/**'
12+
- 'ja/**'
13+
- 'ko/**'
14+
- 'pt-br/**'
15+
- 'ru/**'
16+
- 'sk/**'
17+
- 'th/**'
18+
- 'tr/**'
19+
- 'uk/**'
20+
- 'uz/**'
21+
- 'zh-cn/**'
22+
- 'zh-tw/**'
23+
24+
jobs:
25+
check-translation:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Check modified files and add labels
32+
uses: actions/github-script@v5
33+
with:
34+
script: |
35+
const languages = ['en', 'es', 'fr', 'it', 'ja', 'ko', 'pt-br', 'ru', 'sk', 'th', 'tr', 'uk', 'uz', 'zh-cn', 'zh-tw'];
36+
const { data: pullRequest } = await github.rest.pulls.get({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
pull_number: context.issue.number
40+
});
41+
const { data: files } = await github.rest.pulls.listFiles({
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
pull_number: context.issue.number
45+
});
46+
const modifiedLanguages = new Set(files.map(file => file.filename.split('/')[0]));
47+
const labelsToAdd = languages.filter(lang => !modifiedLanguages.has(lang)).map(lang => `requires-translation-${lang}`);
48+
await github.rest.issues.addLabels({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
issue_number: pullRequest.number,
52+
labels: labelsToAdd
53+
});

0 commit comments

Comments
 (0)