1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- name: Language Sync
- on:
- workflow_dispatch:
- inputs:
- mode:
- description: "Mode"
- required: true
- default: "Full Sync"
- type: choice
- options:
- - Full Sync
- - Download only
- - Upload only
- permissions:
- contents: write
- pull-requests: write
- jobs:
- compare-upload:
- name: "Compare local English"
- runs-on: ubuntu-latest
- if: ${{ inputs.mode != 'Download only' }}
- steps:
- - name: Checkout
- uses: actions/[email protected]
- - name: Compare local reference
- id: upload-comparison
- run: python .github/workflows/localization/reference-comparison.py
- env:
- POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
- POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
- outputs:
- HAS_CHANGES: ${{ steps.upload-comparison.outputs.HAS_CHANGES }}
- upload:
- name: "Upload English changes"
- runs-on: ubuntu-latest
- needs: compare-upload
- environment: poeditor
- if: ${{ needs.compare-upload.outputs.HAS_CHANGES == 'true' }}
- steps:
- - name: Checkout
- uses: actions/[email protected]
- - name: Upload Changes
- run: python .github/workflows/localization/upload-reference.py
- env:
- POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
- POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
- download:
- name: "Download changes"
- runs-on: ubuntu-latest
- if: ${{ inputs.mode != 'Upload only' }}
- steps:
- - name: Checkout
- uses: actions/[email protected]
- - name: Download languages
- id: download-languages
- run: python .github/workflows/localization/download-languages.py
- env:
- POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
- POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
- - name: Create branch
- if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
- run: git checkout -B "language-update-${{ github.run_number }}-${{ github.run_attempt }}"
- - name: Add changes and commit
- if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
- run: |
- git config --global user.name "github-actions[bot]"
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
- git add -A
- git commit -m "Update language files"
- - name: Push changes
- if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
- run: |
- git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
- - name: Create Pull Request
- if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
- run: |
- gh pr create --title "Language Update ${{ github.run_number }}" \
- --body "This PR was created automatically.
- https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs/${{ github.job }}" \
- --base master \
- --head $(git rev-parse --abbrev-ref HEAD)
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|