This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
Crowdin Download Translations #2237
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: Crowdin Download Translations | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 */6 * * *" | |
jobs: | |
download: | |
name: Synchronize with Crowdin | |
runs-on: ubuntu-latest | |
env: | |
UPDATE_BRANCH: ci/update-locale | |
BASE_BRANCH: dev | |
steps: | |
- name: Setup Node | |
uses: actions/[email protected] | |
with: | |
node-version: 18 | |
- name: Install Dependencies | |
run: | | |
yarn global add prettier ts-node @types/node typescript | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Change branch to the update branch | |
id: commits | |
run: | | |
git pull | |
echo "::set-output name=base::$(git rev-parse origin/${{ env.BASE_BRANCH }})" | |
git rev-parse --quiet origin/${{ env.UPDATE_BRANCH }} || git branch ${{ env.UPDATE_BRANCH }} | |
git checkout ${{ env.UPDATE_BRANCH }} | |
echo "::set-output name=update::$(git rev-parse ${{ env.UPDATE_BRANCH }}~)" | |
- name: Use the base branch instead | |
if: ${{ steps.commits.outputs.base != steps.commits.outputs.update }} | |
run: | | |
git checkout ${{ env.BASE_BRANCH }} | |
- name: Download Crowdin Translations | |
uses: crowdin/[email protected] | |
with: | |
upload_sources: false | |
upload_translations: false | |
download_translations: true | |
create_pull_request: false | |
source: locale/en_US.ts | |
translation: locale/%locale_with_underscore%.ts | |
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | |
project_id: ${{ secrets.CROWDIN_PROJECT_ID }} | |
push_translations: false | |
- name: Generate Hashes | |
run: | | |
sudo chown -R $(id -u):$(id -g) locale | |
ts-node -O '{"module": "commonjs"}' scripts/generate_hash.ts | |
prettier --write locale | |
- name: Count lines | |
id: count | |
run: | | |
echo "::set-output name=lines::$(git status --porcelain | wc -l)" | |
- name: Create Pull Request | |
if: ${{ steps.count.outputs.lines != '0' }} | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
title: "[CI] New Crowdin Translations" | |
body: The latest approved translations from Crowdin | |
base: ${{ env.BASE_BRANCH }} | |
branch: ${{ env.UPDATE_BRANCH }} | |
commit-message: Add new locales | |
delete-branch: true | |
add-paths: | | |
locale/* |