Merge pull request #1877 from Admidio/set-admidio-tab-to-default-pref… #43
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: Check Unused Strings | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - languages/en.xml | |
| pull_request: | |
| branches: | |
| - master | |
| paths: | |
| - languages/en.xml | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| unused_found: false | |
| jobs: | |
| unused-strings: | |
| if: ${{ github.repository_owner == 'Admidio' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Run unused-string checker | |
| id: check | |
| run: | | |
| python .github/scripts/check_unused_strings.py --exclude .github,dockerscripts,hooks,libs > unused_keys.txt | |
| if [ -s unused_keys.txt ]; then | |
| echo "unused_found=true" >> $GITHUB_ENV | |
| else | |
| echo "unused_found=false" >> $GITHUB_ENV | |
| fi | |
| - name: Annotate warning if unused | |
| if: env.unused_found == 'true' | |
| run: | | |
| while IFS= read -r key; do | |
| echo "::warning file=languages/en.xml::Unused translation key: $key" | |
| done < unused_keys.txt | |
| - name: Post PR review with unused keys on pull request | |
| if: ${{ github.event_name == 'pull_request' && env.unused_found == 'true' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PR_NUMBER=$(jq --raw-output .number "$GITHUB_EVENT_PATH") | |
| BODY=$(echo -e "**WARNING: Unused translation keys detected**\n\n\`\`\`\n$(cat unused_keys.txt)\n\`\`\`\nPlease consider removing or using these keys." | jq -Rs .) | |
| curl -s -X POST -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews \ | |
| -d "{\"body\": $BODY, \"event\": \"REQUEST_CHANGES\"}" |