Skip to content

Commit b055a50

Browse files
workflow: add automation of syncing translations from Crowdin
This will poll translations from Crowdin bi-weekly, test a build to make sure that the site will compile, and then push to the main branch. This saves the effort of manually syncing translations.
1 parent dc31612 commit b055a50

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/crowdin-commit.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Import translations from Crowdin
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 1,15 * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
persist-credentials: false
16+
17+
- uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: '3.2'
20+
bundler-cache: true
21+
22+
- uses: actions/setup-node@v4
23+
24+
- name: Setup Crowdin CLI
25+
run: |
26+
npm i -g @crowdin/cli
27+
28+
- name: Pull from Crowdin
29+
run: |
30+
CROWDIN_TOKEN=${{ secrets.CROWDIN_TOKEN }} ./crowdin-pull.sh
31+
32+
- name: Pull origin
33+
run: git pull origin main --ff-only # Pull origin in case a commit has been done while updating
34+
35+
# Build the site using Jekyll
36+
# This makes sure that the site actually builds before pushing to Crowdin
37+
- name: Test site build via Jekyll
38+
run: JEKYLL_ENV=production bundle exec jekyll build
39+
40+
- name: Push changes
41+
run: |
42+
git config user.email "[email protected]"
43+
git config user.name "TWLBot"
44+
45+
echo "machine github.com" > "$HOME/.netrc"
46+
echo " login TWLBot" >> "$HOME/.netrc"
47+
echo " password ${{ secrets.TWLBOT_TOKEN }}" >> "$HOME/.netrc"
48+
49+
echo "machine api.github.com" >> "$HOME/.netrc"
50+
echo " login TWLBot" >> "$HOME/.netrc"
51+
echo " password ${{ secrets.TWLBOT_TOKEN }}" >> "$HOME/.netrc"
52+
53+
git checkout main
54+
git stage .
55+
if git commit -m "Automatic translation import"; then
56+
git push origin main
57+
fi

0 commit comments

Comments
 (0)