From ef1051a256a5b4ac2be048c32686905559a46121 Mon Sep 17 00:00:00 2001 From: Rahul Ramesh <121226043+rahu1ramesh@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:57:04 +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_publish_openelis.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 108623ed..aa0af84d 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_publish_openelis.yml b/.github/workflows/build_publish_openelis.yml index 89f8fbe6..104ffbe2 100644 --- a/.github/workflows/build_publish_openelis.yml +++ b/.github/workflows/build_publish_openelis.yml @@ -61,6 +61,6 @@ jobs: tags: bahmni/openelis:${{env.ARTIFACT_VERSION}},bahmni/openelis:latest - name: Push Translations to Transifex run: | - bash .github/scripts/transifex.sh + bash .github/scripts/transifex.sh push env: TX_TOKEN: ${{ secrets.TX_TOKEN }} diff --git a/.github/workflows/pull_translations.yml b/.github/workflows/pull_translations.yml new file mode 100644 index 00000000..3513aad0 --- /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: 'openelis/src/*.properties' + 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