language_sync.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: Sync Multi Language
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. branchName:
  6. description: 'Branch Name'
  7. required: true
  8. excelName:
  9. description: 'Excel Name'
  10. required: true
  11. sheetName:
  12. description: 'Sheet Name'
  13. required: true
  14. jobs:
  15. run-script:
  16. runs-on: ubuntu-latest
  17. permissions:
  18. contents: write
  19. steps:
  20. - name: Check out code
  21. uses: actions/checkout@v3
  22. with:
  23. ref: ${{ github.event.inputs.branchName }}
  24. - name: Set up Python 3
  25. uses: actions/setup-python@v4
  26. with:
  27. python-version: '3.x'
  28. - name: Install dependencies
  29. run: |
  30. cd tool/translate
  31. pip3 install pygsheets
  32. if [ ! -f requirements.txt ]; then
  33. echo "No requirements.txt found, installing default dependencies"
  34. pip install requests pandas
  35. else
  36. pip install -r requirements.txt
  37. fi
  38. - name: Run Python script
  39. run: |
  40. cd tool/translate
  41. python3 synxml.py -f "${{ github.event.inputs.excelName }}" -t "${{ github.event.inputs.sheetName }}"
  42. - name: Commit Language Change
  43. run: |
  44. git config --global user.email "450468291@qq.com"
  45. git config --global user.name "GitHub Action"
  46. git add .
  47. git commit -m "Update Language" || echo "No changes to commit"
  48. git push
  49. env:
  50. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} #设置GitHub Token