localization.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. name: Language Sync
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. mode:
  6. description: "Mode"
  7. required: true
  8. default: "Full Sync"
  9. type: choice
  10. options:
  11. - Full Sync
  12. - Download only
  13. - Upload only
  14. permissions:
  15. contents: write
  16. pull-requests: write
  17. jobs:
  18. compare-upload:
  19. name: "Compare local English"
  20. runs-on: ubuntu-latest
  21. if: ${{ inputs.mode != 'Download only' }}
  22. steps:
  23. - name: Checkout
  24. uses: actions/[email protected]
  25. - name: Compare local reference
  26. id: upload-comparison
  27. run: python .github/workflows/localization/reference-comparison.py
  28. env:
  29. POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
  30. POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
  31. outputs:
  32. HAS_CHANGES: ${{ steps.upload-comparison.outputs.HAS_CHANGES }}
  33. upload:
  34. name: "Upload English changes"
  35. runs-on: ubuntu-latest
  36. needs: compare-upload
  37. environment: poeditor
  38. if: ${{ needs.compare-upload.outputs.HAS_CHANGES == 'true' }}
  39. steps:
  40. - name: Checkout
  41. uses: actions/[email protected]
  42. - name: Upload Changes
  43. run: python .github/workflows/localization/upload-reference.py
  44. env:
  45. POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
  46. POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
  47. download:
  48. name: "Download changes"
  49. runs-on: ubuntu-latest
  50. if: ${{ inputs.mode != 'Upload only' }}
  51. steps:
  52. - name: Checkout
  53. uses: actions/[email protected]
  54. - name: Download languages
  55. id: download-languages
  56. run: python .github/workflows/localization/download-languages.py
  57. env:
  58. POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
  59. POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
  60. - name: Create branch
  61. if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
  62. run: git checkout -B "language-update-${{ github.run_number }}-${{ github.run_attempt }}"
  63. - name: Add changes and commit
  64. if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
  65. run: |
  66. git config --global user.name "github-actions[bot]"
  67. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  68. git add -A
  69. git commit -m "Update language files"
  70. - name: Push changes
  71. if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
  72. run: |
  73. git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
  74. - name: Create Pull Request
  75. if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
  76. run: |
  77. gh pr create --title "Language Update ${{ github.run_number }}" \
  78. --body "This PR was created automatically.
  79. https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs/${{ github.job }}" \
  80. --base master \
  81. --head $(git rev-parse --abbrev-ref HEAD)
  82. env:
  83. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}