New Crowdin updates #676
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Normalize Crowdin TS Files | |
| on: | |
| pull_request_target: | |
| branches: | |
| - master | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| normalize-ts: | |
| if: > | |
| github.event.pull_request.head.ref == 'l10n_master' && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| persist-credentials: true | |
| - name: Install Qt tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qt6-l10n-tools | |
| echo "/usr/lib/qt6/bin" >> $GITHUB_PATH | |
| - name: Normalize TS files | |
| run: | | |
| find . -name "*.ts" | while read f; do | |
| echo "Normalizing $f" | |
| lconvert -sort-contexts -o "$f.tmp" "$f" | |
| mv "$f.tmp" "$f" | |
| done | |
| - name: Commit normalization changes | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git add . | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Normalize Qt TS files" | |
| git push origin HEAD:${{ github.event.pull_request.head.ref }} | |
| else | |
| echo "No normalization changes" | |
| fi | |
| - name: Fetch target branch | |
| run: | | |
| git fetch origin ${{ github.event.pull_request.base.ref }} | |
| - name: Check whether PR is empty | |
| id: check_empty | |
| run: | | |
| if git diff --quiet origin/${{ github.event.pull_request.base.ref }}...HEAD; then | |
| echo "empty=true" >> $GITHUB_OUTPUT | |
| echo "PR became empty after normalization" | |
| else | |
| echo "empty=false" >> $GITHUB_OUTPUT | |
| echo "PR still contains semantic changes" | |
| fi | |
| - name: Close empty PR | |
| if: steps.check_empty.outputs.empty == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.pulls.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| state: 'closed' | |
| }); |