translate-i18n-base-on-english.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. name: Check i18n Files and Create PR
  2. on:
  3. pull_request:
  4. types: [closed]
  5. branches: [main]
  6. jobs:
  7. check-and-update:
  8. if: github.event.pull_request.merged == true
  9. runs-on: ubuntu-latest
  10. defaults:
  11. run:
  12. working-directory: web
  13. steps:
  14. - uses: actions/checkout@v4
  15. with:
  16. fetch-depth: 2 # last 2 commits
  17. - name: Check for file changes in i18n/en-US
  18. id: check_files
  19. run: |
  20. recent_commit_sha=$(git rev-parse HEAD)
  21. second_recent_commit_sha=$(git rev-parse HEAD~1)
  22. changed_files=$(git diff --name-only $recent_commit_sha $second_recent_commit_sha -- 'i18n/en-US/*.ts')
  23. echo "Changed files: $changed_files"
  24. if [ -n "$changed_files" ]; then
  25. echo "FILES_CHANGED=true" >> $GITHUB_ENV
  26. else
  27. echo "FILES_CHANGED=false" >> $GITHUB_ENV
  28. fi
  29. - name: Set up Node.js
  30. if: env.FILES_CHANGED == 'true'
  31. uses: actions/setup-node@v2
  32. with:
  33. node-version: 'lts/*'
  34. - name: Install dependencies
  35. if: env.FILES_CHANGED == 'true'
  36. run: yarn install --frozen-lockfile
  37. - name: Run npm script
  38. if: env.FILES_CHANGED == 'true'
  39. run: npm run auto-gen-i18n
  40. - name: Create Pull Request
  41. if: env.FILES_CHANGED == 'true'
  42. uses: peter-evans/create-pull-request@v6
  43. with:
  44. commit-message: Update i18n files based on en-US changes
  45. title: 'chore: translate i18n files'
  46. body: This PR was automatically created to update i18n files based on changes in en-US locale.
  47. branch: chore/automated-i18n-updates