Skip to content

Commit 3aa6427

Browse files
authored
Merge pull request #12696 from ethereum/build-crowdin
feat: Crowdin build automation
2 parents 5006b1b + b867eb0 commit 3aa6427

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

.github/workflows/build-crowdin.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build Crowdin project
2+
3+
on:
4+
schedule:
5+
- cron: "20 04 1 * *" # Runs at 4:20 AM on the first day of every month
6+
workflow_dispatch:
7+
8+
jobs:
9+
create_pr:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
20+
- name: Install dependencies
21+
run: yarn install
22+
23+
- name: Install ts-node
24+
run: yarn global add ts-node
25+
26+
- name: Run script
27+
run: npx ts-node -O '{"module":"commonjs"}' ./src/scripts/crowdin/translations/triggerBuild.ts
28+
env:
29+
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
30+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}

src/scripts/crowdin/getTranslationProgress.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ async function main() {
2424

2525
const progress = response.data.map(
2626
({ data }) =>
27-
({
28-
languageId: data.languageId,
29-
words: {
30-
approved: data.words.approved,
31-
total: data.words.total,
32-
},
33-
} as ProjectProgressData)
27+
({
28+
languageId: data.languageId,
29+
words: {
30+
approved: data.words.approved,
31+
total: data.words.total,
32+
},
33+
} as ProjectProgressData)
3434
)
3535

3636
fs.writeFileSync(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import crowdin from "../api-client/crowdinClient"
2+
3+
import "dotenv/config"
4+
5+
async function triggerBuild() {
6+
const projectId = Number(process.env.CROWDIN_PROJECT_ID) || 363359
7+
8+
try {
9+
await crowdin.translationsApi.buildProject(projectId, {
10+
exportApprovedOnly: true,
11+
})
12+
} catch (error: unknown) {
13+
console.error((error as Error).message)
14+
}
15+
}
16+
17+
triggerBuild()
18+
19+
export default triggerBuild

0 commit comments

Comments
 (0)