Files
trezor-suite/.github/workflows/bot-crowdin-sync.yml

84 lines
2.9 KiB
YAML

name: "[Bot] Crowdin translations update"
on:
workflow_dispatch:
inputs:
remove_unused_translations:
description: "Confirm removal of unused translations. Check them first in misc tests pipeline."
required: true
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
crowdin-sync:
if: github.repository == 'trezor/trezor-suite'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Set current timestamp as env variable
run: echo "NOW=$(date +'%s')" >> $GITHUB_ENV
- name: Install dependencies
run: yarn install
- name: Set source branch
run: echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Generate GitHub App token
id: trezor-bot-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TREZOR_BOT_APP_ID }}
private-key: ${{ secrets.TREZOR_BOT_PRIVATE_KEY }}
- name: Run crowdin sync
run: |
git config --global user.name "trezor-ci"
git config --global user.email "${{ secrets.TREZOR_BOT_EMAIL }}"
git checkout -B ${{ env.BRANCH_NAME }}
yarn workspace @trezor/suite translations:download --token=${{ secrets.CROWDIN_PERSONAL_TOKEN }}
yarn workspace @trezor/suite translations:backport-en
if [ "${{ github.event.inputs.remove_unused_translations }}" = "true" ]; then
yarn workspace @trezor/suite translations:list-unused --cleanup
fi
yarn workspace @trezor/suite translations:format
yarn workspace @trezor/suite translations:extract
cat packages/suite-data/files/translations/master.json
yarn workspace @trezor/suite translations:upload --token=${{ secrets.CROWDIN_PERSONAL_TOKEN }}
if [[ "${{ env.SOURCE_BRANCH }}" == release/* ]]; then
SUFFIX=" [RELEASE ONLY]"
else
SUFFIX=""
fi
COMMIT_MSG="chore: crowdin translation update${SUFFIX}"
PR_TITLE="Crowdin translations update${SUFFIX}"
git add .
git commit -m "$COMMIT_MSG"
git push origin ${{ env.BRANCH_NAME }} -f
gh config set prompt disabled
gh pr create \
--repo trezor/trezor-suite \
--title "$PR_TITLE" \
--body "Automatically generated PR for updating crowdin translations from ${{ env.SOURCE_BRANCH }} branch." \
--base ${{ env.SOURCE_BRANCH }} \
--label translations \
--label no-project
env:
GITHUB_TOKEN: ${{ steps.trezor-bot-token.outputs.token }}
BRANCH_NAME: trezor-ci/crowdin-sync-${{ env.NOW }}