mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-03 05:55:03 +01:00
123 lines
4.7 KiB
YAML
123 lines
4.7 KiB
YAML
name: "[Bot] Crowdin translations update"
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
platform:
|
|
type: choice
|
|
options:
|
|
- desktop
|
|
- mobile
|
|
description: Should be synced desktop or mobile crowdin project?
|
|
required: true
|
|
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.event.inputs.platform }}-${{ 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"
|
|
cache: yarn
|
|
|
|
- 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: Checkout new branch
|
|
run: |
|
|
git config --global user.name "trezor-ci"
|
|
git config --global user.email "${{ secrets.TREZOR_BOT_EMAIL }}"
|
|
BRANCH_NAME="trezor-ci/crowdin-sync-${{ github.event.inputs.platform }}-${{ env.NOW }}"
|
|
git checkout -B ${BRANCH_NAME}
|
|
|
|
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
|
|
|
|
- name: Run crowdin sync [desktop]
|
|
if: github.event.inputs.platform == 'desktop'
|
|
run: |
|
|
yarn workspace @suite/intl translations:download --token=${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
yarn workspace @suite/intl translations:backport-en
|
|
if [ "${{ github.event.inputs.remove_unused_translations }}" = "true" ]; then
|
|
yarn workspace @suite/intl translations:list-unused --cleanup
|
|
fi
|
|
yarn workspace @suite/intl translations:format
|
|
yarn workspace @suite/intl translations:extract
|
|
cat packages/suite-data/files/translations/master.json
|
|
yarn workspace @suite/intl translations:upload --token=${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
|
|
- name: Run crowdin sync [mobile]
|
|
if: github.event.inputs.platform == 'mobile'
|
|
run: |
|
|
yarn workspace @suite-native/intl translations:download --token=${{ secrets.CROWDIN_PERSONAL_TOKEN_MOBILE }}
|
|
yarn workspace @suite-native/intl translations:backport-en
|
|
if [ "${{ github.event.inputs.remove_unused_translations }}" = "true" ]; then
|
|
yarn workspace @suite-native/intl translations:remove-unused
|
|
fi
|
|
yarn workspace @suite-native/intl translations:format
|
|
yarn workspace @suite-native/intl translations:extract
|
|
cat suite-native/intl/translations/master.json
|
|
yarn workspace @suite-native/intl translations:upload --token=${{ secrets.CROWDIN_PERSONAL_TOKEN_MOBILE }}
|
|
|
|
- name: create translations PR
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.trezor-bot-token.outputs.token }}
|
|
run: |
|
|
if [ "${{ github.event.inputs.platform }}" = "desktop" ]; then
|
|
PR_TITLE="Crowdin translations update [DESKTOP]"
|
|
PR_BODY="Automatically generated PR for updating DESKTOP crowdin translations from ${{ env.SOURCE_BRANCH }} branch."
|
|
COMMIT_SCOPE="suite"
|
|
else
|
|
PR_TITLE="Crowdin translations update [MOBILE]"
|
|
PR_BODY="Automatically generated PR for updating MOBILE crowdin translations from ${{ env.SOURCE_BRANCH }} branch."
|
|
COMMIT_SCOPE="suite-native"
|
|
fi
|
|
|
|
if [[ "${{ env.SOURCE_BRANCH }}" == release/* ]] || [[ "${{ env.SOURCE_BRANCH }}" == release-native/* ]]; then
|
|
SUFFIX=" [RELEASE ONLY]"
|
|
else
|
|
SUFFIX=""
|
|
fi
|
|
|
|
COMMIT_MSG="chore(${COMMIT_SCOPE}): crowdin translation 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}${SUFFIX}" \
|
|
--body "${PR_BODY}" \
|
|
--base ${{ env.SOURCE_BRANCH }} \
|
|
--label translations \
|
|
--label ${{ github.event.inputs.platform }} \
|
|
--label no-project
|