Sync translations to other languages #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync translations to other languages | |
on: | |
push: | |
paths: | |
- "en-US/**.json" | |
branches: | |
- "**/stable" | |
workflow_dispatch: | |
jobs: | |
sync_translations: | |
name: Sync translations | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "14" | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm install | |
- name: Install jq (JSON processor) | |
uses: dcarbone/install-jq-action@main | |
- name: Copy new JSON files to other languages | |
run: | | |
for lang_dir in $(find . -mindepth 1 -maxdepth 1 -type d -name "*-*" | grep -E '[a-z]{2}-[A-Z]{2}'); do | |
lang=$(basename "$lang_dir") | |
find en-US -type f -name "*.json" | while read file; do | |
new_file="${file/en-US/$lang}" | |
if [ ! -f "$new_file" ]; then | |
mkdir -p "$(dirname "$new_file")" | |
cp "$file" "$new_file" | |
echo "Created $new_file in $lang" | |
fi | |
done | |
done | |
- name: Commit changes | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
git add . | |
git commit -m "Add new translation files for other languages" | |
- name: Create a pull request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Add new translation files for other languages" | |
branch: "auto/sync-translations-${{ github.ref_name }}" | |
title: "Sync translations in ${{ github.ref_name }}" | |
body: "This PR adds new translation files for the branch **${{ github.ref_name }}**." | |
assignees: ilxlodev | |
reviewers: ilxlodev | |
labels: syncronization, blocked | |
base: ${{ github.ref_name }} |