Skip to content

Commit 00adb3e

Browse files
committed
Add workflows to push and pull translations from Transifex and check source file is updated when necessary
1 parent aab4fc5 commit 00adb3e

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

Diff for: .github/workflows/check-i18n-task.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Check Internationalization
2+
3+
env:
4+
# See: https://github.com/actions/setup-go/tree/v2#readme
5+
GO_VERSION: '1.16'
6+
7+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
8+
on:
9+
create:
10+
push:
11+
paths:
12+
- '.github/workflows/check-i18n-task.ya?ml'
13+
- 'package.json'
14+
- '**/package.json'
15+
- '**.ts'
16+
- 'i18n/**'
17+
pull_request:
18+
paths:
19+
- '.github/workflows/check-i18n-task.ya?ml'
20+
- 'package.json'
21+
- '**/package.json'
22+
- '**.ts'
23+
- 'i18n/**'
24+
workflow_dispatch:
25+
repository_dispatch:
26+
27+
jobs:
28+
run-determination:
29+
runs-on: ubuntu-latest
30+
outputs:
31+
result: ${{ steps.determination.outputs.result }}
32+
steps:
33+
- name: Determine if the rest of the workflow should run
34+
id: determination
35+
run: |
36+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
37+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
38+
if [[ \
39+
"${{ github.event_name }}" != "create" || \
40+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
41+
]]; then
42+
# Run the other jobs.
43+
RESULT="true"
44+
else
45+
# There is no need to run the other jobs.
46+
RESULT="false"
47+
fi
48+
49+
echo "::set-output name=result::$RESULT"
50+
51+
check:
52+
needs: run-determination
53+
if: needs.run-determination.outputs.result == 'true'
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v2
59+
60+
- name: Install Node.js 12.x
61+
uses: actions/setup-node@v1
62+
with:
63+
node-version: '12.14.1'
64+
registry-url: 'https://registry.npmjs.org'
65+
66+
- name: Check for errors
67+
run: yarn i18n:check

Diff for: .github/workflows/i18n-nightly-push.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: i18n-nightly-push
2+
3+
on:
4+
schedule:
5+
# run every day at 1AM
6+
- cron: '0 1 * * *'
7+
8+
jobs:
9+
push-to-transifex:
10+
# This workflow is only of value to the arduino/arduino-ide repository and
11+
# would always fail in forks
12+
if: github.repository == 'arduino/arduino-ide'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Install Node.js 12.x
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: '12.14.1'
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
- name: Run i18n:push script
25+
run: yarn run i18n:push
26+
env:
27+
TRANSIFEX_ORGANIZATION: ${{ secrets.TRANSIFEX_ORGANIZATION }}
28+
TRANSIFEX_PROJECT: ${{ secrets.TRANSIFEX_PROJECT }}
29+
TRANSIFEX_RESOURCE: ${{ secrets.TRANSIFEX_RESOURCE }}
30+
TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}

Diff for: .github/workflows/i18n-weekly-pull.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: i18n-weekly-pull
2+
3+
on:
4+
schedule:
5+
# run every monday at 2AM
6+
- cron: '0 2 * * 1'
7+
8+
jobs:
9+
pull-from-transifex:
10+
# This workflow is only of value to the arduino/arduino-ide repository and
11+
# would always fail in forks
12+
if: github.repository == 'arduino/arduino-ide'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Install Node.js 12.x
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: '12.14.1'
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
- name: Run i18n:pull script
25+
run: yarn run i18n:pull
26+
env:
27+
TRANSIFEX_ORGANIZATION: ${{ secrets.TRANSIFEX_ORGANIZATION }}
28+
TRANSIFEX_PROJECT: ${{ secrets.TRANSIFEX_PROJECT }}
29+
TRANSIFEX_RESOURCE: ${{ secrets.TRANSIFEX_RESOURCE }}
30+
TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}
31+
32+
- name: Create Pull Request
33+
uses: peter-evans/create-pull-request@v3
34+
with:
35+
commit-message: Updated translation files
36+
title: Updated translation files
37+
branch: i18n/translations-update
38+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

0 commit comments

Comments
 (0)