Skip to content

Commit

Permalink
[Rahu] | BAH-3644 | Add. Workflow To Pull Translations
Browse files Browse the repository at this point in the history
This workflow is designed to retrieve translations from Transifex once every month in case resources are updated.
  • Loading branch information
rahu1ramesh committed Mar 6, 2024
1 parent da37fd1 commit 9d2d3ac
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
16 changes: 12 additions & 4 deletions .github/scripts/transifex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/pull_translations.yml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
commit_author: bahmni-infra <[email protected]>

- 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

0 comments on commit 9d2d3ac

Please sign in to comment.