From 9d2d3ac7848adf52dbfe9997be8f6aad00f7da55 Mon Sep 17 00:00:00 2001 From: Rahul Ramesh <121226043+rahu1ramesh@users.noreply.github.com> Date: Mon, 4 Mar 2024 19:24:58 +0530 Subject: [PATCH] [Rahu] | BAH-3644 | Add. Workflow To Pull Translations This workflow is designed to retrieve translations from Transifex once every month in case resources are updated. --- .github/scripts/transifex.sh | 16 ++++++--- .github/workflows/build_upload.yml | 2 +- .github/workflows/pull_translations.yml | 43 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pull_translations.yml diff --git a/.github/scripts/transifex.sh b/.github/scripts/transifex.sh index 108623ed7..aa0af84d3 100644 --- a/.github/scripts/transifex.sh +++ b/.github/scripts/transifex.sh @@ -15,12 +15,20 @@ if [ ! -f .tx/config ]; then exit 1 fi -echo "Pushing translation source file to Transifex..." -tx push -s +if [ "$1" == "push" ]; then + echo "Pushing translation source file to Transifex..." + tx push -s +elif [ "$1" == "pull" ]; then + echo "Pulling translations from Transifex..." + tx pull -t -s --mode reviewed --use-git-timestamps +else + echo "Invalid operation. Please specify either 'push' or 'pull'." + exit 1 +fi if [ $? -ne 0 ]; then - echo "Error: Transifex push failed. Please check the error message above." + echo "Error: Transifex operation failed. Please check the error message above." exit 1 else - echo "Translation source file successfully pushed to Transifex." + echo "Transifex operation completed successfully." fi \ No newline at end of file diff --git a/.github/workflows/build_upload.yml b/.github/workflows/build_upload.yml index f770d8a31..af204f10d 100644 --- a/.github/workflows/build_upload.yml +++ b/.github/workflows/build_upload.yml @@ -41,7 +41,7 @@ jobs: tags: bahmni/default-config:${{env.ARTIFACT_VERSION}},bahmni/default-config:latest - name: Push Translations to Transifex run: | - bash .github/scripts/transifex.sh + bash .github/scripts/transifex.sh push env: TX_TOKEN: ${{ secrets.TX_TOKEN }} - name: Update Version and Image Tag diff --git a/.github/workflows/pull_translations.yml b/.github/workflows/pull_translations.yml new file mode 100644 index 000000000..003b2647a --- /dev/null +++ b/.github/workflows/pull_translations.yml @@ -0,0 +1,43 @@ +name: Pull Translations from Transifex + +on: + schedule: + - cron: '0 0 1 * *' + workflow_dispatch: + +jobs: + pull-translations: + name: Pull Translations from Transifex + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Pull Translations from Transifex + run: | + bash .github/scripts/transifex.sh pull + env: + TX_TOKEN: ${{ secrets.TX_TOKEN }} + + - name: Commit and push changes + id: auto-commit-action + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "[Bahmni Infra] | Add. Update Translation Resources" + branch: ${{ github.ref }} + file_pattern: 'openmrs/i18n/**/*.json' + repository: . + commit_user_name: Bahmni Infra + commit_user_email: infrastructure@bahmni.org + commit_author: bahmni-infra + + - name: Check for changes + run: | + if [[ steps.auto-commit-action.outputs.changes_detected == 'true' ]]; then + echo "Changes Detected. Translation Resources Updated." + else + echo "No Changes Detected. Project Already Up-To-Date." + fi \ No newline at end of file