Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Crowdin automation scripts #2466

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/crowdin-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Import translations from Crowdin

on:
schedule:
- cron: "0 0 1,15 * *"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- uses: actions/setup-node@v4

- name: Setup Crowdin CLI
run: |
npm i -g @crowdin/cli

- name: Pull from Crowdin
run: |
CROWDIN_TOKEN=${{ secrets.CROWDIN_TOKEN }} ./crowdin-pull.sh

- name: Pull origin
run: git pull origin main --ff-only # Pull origin in case a commit has been done while updating

# Build the site using Jekyll
# This makes sure that the site actually builds before pushing to Crowdin
- name: Test site build via Jekyll
run: JEKYLL_ENV=production bundle exec jekyll build

- name: Push changes
run: |
git config user.email "[email protected]"
git config user.name "TWLBot"

echo "machine github.com" > "$HOME/.netrc"
echo " login TWLBot" >> "$HOME/.netrc"
echo " password ${{ secrets.TWLBOT_TOKEN }}" >> "$HOME/.netrc"

echo "machine api.github.com" >> "$HOME/.netrc"
echo " login TWLBot" >> "$HOME/.netrc"
echo " password ${{ secrets.TWLBOT_TOKEN }}" >> "$HOME/.netrc"

git checkout main
git stage .
if git commit -m "Automatic translation import"; then
git push origin main
fi
34 changes: 34 additions & 0 deletions .github/workflows/crowdin-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Upload source files to Crowdin

on:
push:
branches: [ main ]
paths:
- '_pages/en_US/**.txt'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

# Build the site using Jekyll
# No point pushing to Crowdin if the site build is failing
- name: Test site build via Jekyll
run: JEKYLL_ENV=production bundle exec jekyll build

- name: Push to Crowdin
uses: crowdin/github-action@v2
with:
upload_sources: true
env:
CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }}