update.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. name: Update translations
  2. on:
  3. schedule:
  4. - cron: '0 */6 * * *' # https://crontab.guru/#0_*/12_*_*_*
  5. workflow_dispatch: # allow manual trigger
  6. push:
  7. branches:
  8. - master
  9. paths-ignore:
  10. - '**.ts'
  11. jobs:
  12. lock-weblate:
  13. runs-on: ubuntu-latest
  14. container:
  15. image: weblate/wlc
  16. options: "-u root:root"
  17. steps:
  18. - name: Lock Weblate
  19. run: |
  20. mkdir -p ~/.config
  21. echo "${{ secrets.WEBLATE_CONFIG }}" > ~/.config/weblate
  22. wlc commit "polymc/polymc"
  23. wlc lock "polymc/polymc"
  24. update:
  25. needs: lock-weblate
  26. runs-on: ubuntu-latest
  27. steps:
  28. - uses: actions/checkout@v3
  29. with:
  30. fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
  31. - name: Prepare
  32. run: |
  33. sudo apt-get update
  34. sudo apt-get install -y qttools5-dev-tools gettext
  35. git config --local user.email "gitbot@scrumplex.net"
  36. git config --local user.name "Translations Bot"
  37. - name: Ensure updated translations
  38. run: |
  39. # pull latest translations manually to avoid conflicts
  40. git pull # maybe Weblate already pushed their changes
  41. git remote add weblate https://hosted.weblate.org/git/polymc/polymc
  42. git remote update
  43. git merge weblate/master
  44. - name: Update translations
  45. run: |
  46. git clone https://github.com/PolyMC/PolyMC.git src
  47. ./update.sh
  48. - name: Commit files
  49. run: |
  50. git commit -m "Update source strings" -a || true
  51. - name: Push changes
  52. uses: ad-m/github-push-action@master
  53. with:
  54. github_token: ${{ secrets.GITHUB_TOKEN }}
  55. branch: ${{ github.ref }}
  56. unlock-weblate:
  57. needs: update
  58. if: ${{ always() }} # ensure that this runs, even if something failed
  59. runs-on: ubuntu-latest
  60. container:
  61. image: weblate/wlc
  62. options: "-u root:root"
  63. steps:
  64. - name: Unlock Weblate
  65. run: |
  66. mkdir -p ~/.config
  67. echo "${{ secrets.WEBLATE_CONFIG }}" > ~/.config/weblate
  68. wlc pull "polymc/polymc"
  69. wlc unlock "polymc/polymc"