From 8734ae27c31c3b0786d451f77775a4eb965c32cc Mon Sep 17 00:00:00 2001 From: Patrick Honkonen Date: Mon, 17 Jun 2024 09:30:38 -0400 Subject: [PATCH 1/4] [BWA-28] Sync translations with Crowdin --- .github/workflows/crowdin-pull.yml | 50 ++++++++++++++++++ .github/workflows/crowdin-push.yml | 82 ++++++++++++++++++++++++++++++ crowdin.yml | 8 +++ 3 files changed, 140 insertions(+) create mode 100644 .github/workflows/crowdin-pull.yml create mode 100644 .github/workflows/crowdin-push.yml create mode 100644 crowdin.yml diff --git a/.github/workflows/crowdin-pull.yml b/.github/workflows/crowdin-pull.yml new file mode 100644 index 000000000..21818dfc1 --- /dev/null +++ b/.github/workflows/crowdin-pull.yml @@ -0,0 +1,50 @@ +name: Crowdin Sync + +on: + workflow_dispatch: + inputs: {} + schedule: + - cron: '0 0 * * 5' + +jobs: + crowdin-sync: + name: Autosync + runs-on: ubuntu-20.04 + env: + _CROWDIN_PROJECT_ID: "673718" + steps: + - name: Check out repo + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + + - name: Log in to Azure - CI Subscription + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "crowdin-api-token, github-gpg-private-key, github-gpg-private-key-passphrase" + + - name: Download translations + uses: crowdin/github-action@67705afb6985401459cd143d5f5f00c9dc212f23 # v1.20.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }} + with: + config: crowdin.yml + crowdin_branch_name: main + upload_sources: false + upload_translations: false + download_translations: true + github_user_name: "bitwarden-devops-bot" + github_user_email: "106330231+bitwarden-devops-bot@users.noreply.github.com" + commit_message: "Autosync the updated translations" + localization_branch_name: crowdin-auto-sync + create_pull_request: true + pull_request_title: "Autosync Crowdin Translations" + pull_request_body: "Autosync the updated translations" + gpg_private_key: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key }} + gpg_passphrase: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key-passphrase }} diff --git a/.github/workflows/crowdin-push.yml b/.github/workflows/crowdin-push.yml new file mode 100644 index 000000000..8a2ade669 --- /dev/null +++ b/.github/workflows/crowdin-push.yml @@ -0,0 +1,82 @@ +name: Crowdin Push + +on: + workflow_dispatch: + push: + branches: + - "main" +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JAVA_VERSION: 17 + +jobs: + crowdin-push: + name: Crowdin Push + runs-on: ubuntu-22.04 + env: + _CROWDIN_PROJECT_ID: "673718" + steps: + - name: Check out repo + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@b5418f5a58f5fd2eb486dd7efb368fe7be7eae45 # v2.1.3 + + - name: Cache Gradle files + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }} + restore-keys: | + ${{ runner.os }}-gradle-v2- + + - name: Cache build output + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: | + ${{ github.workspace }}/build-cache + key: ${{ runner.os }}-build-cache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-build- + + - name: Configure JDK + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + with: + distribution: "temurin" + java-version: ${{ env.JAVA_VERSION }} + + - name: Configure Ruby + uses: ruby/setup-ruby@0cde4689ba33c09f1b890c1725572ad96751a3fc # v1.178.0 + with: + bundler-cache: true + + - name: Install Fastlane + run: | + gem install bundler:2.2.27 + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: Log in to Azure + uses: Azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1.6.1 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "crowdin-api-token" + + - name: Upload sources + uses: crowdin/github-action@67705afb6985401459cd143d5f5f00c9dc212f23 # v1.20.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }} + with: + config: crowdin.yml + crowdin_branch_name: main + upload_sources: true + upload_translations: false diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 000000000..e29b811a5 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,8 @@ +project_id_env: _CROWDIN_PROJECT_ID +api_token_env: CROWDIN_API_TOKEN +preserve_hierarchy: true +base_path: "app/src/main" +files: + - source: "/res/values/strings.xml" + translation: "/res/values-%android_code%/%original_fil_name%" + update_option: update_as_unapproved From 5fc36eb2338a6b691247f029e6e207ba788b622b Mon Sep 17 00:00:00 2001 From: Patrick Honkonen Date: Mon, 17 Jun 2024 09:36:58 -0400 Subject: [PATCH 2/4] Declare file types explicitly --- crowdin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/crowdin.yml b/crowdin.yml index e29b811a5..47bdd5165 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -6,3 +6,4 @@ files: - source: "/res/values/strings.xml" translation: "/res/values-%android_code%/%original_fil_name%" update_option: update_as_unapproved + type: android From d7c0145b8b66398fbf1cd7a0d828aae592591e2f Mon Sep 17 00:00:00 2001 From: Patrick Honkonen Date: Mon, 17 Jun 2024 09:42:22 -0400 Subject: [PATCH 3/4] Remove unnecessary push steps --- .github/workflows/crowdin-push.yml | 39 ------------------------------ 1 file changed, 39 deletions(-) diff --git a/.github/workflows/crowdin-push.yml b/.github/workflows/crowdin-push.yml index 8a2ade669..73d9f066f 100644 --- a/.github/workflows/crowdin-push.yml +++ b/.github/workflows/crowdin-push.yml @@ -19,45 +19,6 @@ jobs: - name: Check out repo uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@b5418f5a58f5fd2eb486dd7efb368fe7be7eae45 # v2.1.3 - - - name: Cache Gradle files - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }} - restore-keys: | - ${{ runner.os }}-gradle-v2- - - - name: Cache build output - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: | - ${{ github.workspace }}/build-cache - key: ${{ runner.os }}-build-cache-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-build- - - - name: Configure JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 - with: - distribution: "temurin" - java-version: ${{ env.JAVA_VERSION }} - - - name: Configure Ruby - uses: ruby/setup-ruby@0cde4689ba33c09f1b890c1725572ad96751a3fc # v1.178.0 - with: - bundler-cache: true - - - name: Install Fastlane - run: | - gem install bundler:2.2.27 - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 - - name: Log in to Azure uses: Azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1.6.1 with: From 47d8a457e50a54fb60616e99f6ec1b1a2db65742 Mon Sep 17 00:00:00 2001 From: Patrick Honkonen Date: Mon, 17 Jun 2024 10:35:39 -0400 Subject: [PATCH 4/4] Correct typo in translation path --- crowdin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdin.yml b/crowdin.yml index 47bdd5165..725469a19 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -4,6 +4,6 @@ preserve_hierarchy: true base_path: "app/src/main" files: - source: "/res/values/strings.xml" - translation: "/res/values-%android_code%/%original_fil_name%" + translation: "/res/values-%android_code%/%original_file_name%" update_option: update_as_unapproved type: android