Skip to content

Synchronize Translations #9

Synchronize Translations

Synchronize Translations #9

name: Synchronize Translations
on:
schedule:
- cron: 30 5 * * 2 # tuesday morning, UTC
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
synchronize-translations:
name: Synchronize Translations
env:
BRANCH_NAME: update-translations-${{ github.run_id }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
- name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend
- name: Prepare back-end environment
uses: ./.github/actions/prepare-backend
- name: install gettext
run: sudo apt-get install gettext
- name: Crowdin download
uses: crowdin/github-action@v2
id: crowdin-download
with:
config: locales/crowdin.yml
command: download
command_args: |
--config locales/crowdin.yml
-e=el
-e=et
-e=es-MX
-e=gu-IN
-e=hr
-e=lt
-e=km
-e=pt-PT
-e=ro
-e=th
-e=uz
- name: Prepare translation resources
env:
GITHUB_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
run: | # sh
git config user.name github-actions
git config user.email github-actions@github.com
git checkout -b $BRANCH_NAME
DATE=$(date +'%Y-%m-%d')
./bin/i18n/update-translation-template
git add locales/metabase.po
git commit -m "Update translation sources $DATE" --no-verify
./bin/i18n/build-translation-resources
git add locales/
git commit -a -m "Update translations $Date" --allow-empty --no-verify
git push -u origin $BRANCH_NAME
- name: Crowdin upload
uses: crowdin/github-action@v2
id: crowdin-upload
env:
GITHUB_TOKEN: ${{ github.token }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
with:
config: locales/crowdin.yml
command: upload
command_args: --config locales/crowdin.yml
- name: Open PR
id: create_pr
env:
GITHUB_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
run: | # sh
DATE=$(date +'%Y-%m-%d')
URL=$(gh pr create \
--base master \
--head $BRANCH_NAME \
--title "Update translations $DATE" \
--body "Synchronize translations with Crowdin" \
--label "no-backport" \
--label "Customization/i18n")
PR_NUMBER=${URL##*/}
echo "::set-output name=pr_number::$PR_NUMBER"
- name: Auto approve PR
uses: juliangruber/approve-pull-request-action@v1
with:
github-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
number: ${{ steps.create_pr.outputs.pr_number }}
- name: Enable Pull Request Automerge
uses: peter-evans/enable-pull-request-automerge@v2
with:
token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
pull-request-number: ${{ steps.create_pr.outputs.pr_number }}
merge-method: squash