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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. persist-credentials: false
  18. - name: Check for file changes in i18n/en-US
  19. id: check_files
  20. run: |
  21. recent_commit_sha=$(git rev-parse HEAD)
  22. second_recent_commit_sha=$(git rev-parse HEAD~1)
  23. changed_files=$(git diff --name-only $recent_commit_sha $second_recent_commit_sha -- 'i18n/en-US/*.ts')
  24. echo "Changed files: $changed_files"
  25. if [ -n "$changed_files" ]; then
  26. echo "FILES_CHANGED=true" >> $GITHUB_ENV
  27. else
  28. echo "FILES_CHANGED=false" >> $GITHUB_ENV
  29. fi
  30. - name: Set up Node.js
  31. if: env.FILES_CHANGED == 'true'
  32. uses: actions/setup-node@v2
  33. with:
  34. node-version: 'lts/*'
  35. - name: Install dependencies
  36. if: env.FILES_CHANGED == 'true'
  37. run: pnpm install --frozen-lockfile
  38. - name: Run npm script
  39. if: env.FILES_CHANGED == 'true'
  40. run: pnpm run auto-gen-i18n
  41. - name: Create Pull Request
  42. if: env.FILES_CHANGED == 'true'
  43. uses: peter-evans/create-pull-request@v6
  44. with:
  45. commit-message: Update i18n files based on en-US changes
  46. title: 'chore: translate i18n files'
  47. body: This PR was automatically created to update i18n files based on changes in en-US locale.
  48. branch: chore/automated-i18n-updates