diff --git a/.github/workflows/label_translation-pr.yml b/.github/workflows/label_translation-pr.yml new file mode 100644 index 000000000..5dbe92fc5 --- /dev/null +++ b/.github/workflows/label_translation-pr.yml @@ -0,0 +1,38 @@ +name: Label translation PRs + +on: + pull_request_target: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +jobs: + label-translation: + runs-on: ubuntu-latest + steps: + - name: Fetch PR diff + env: + GH_TOKEN: ${{ github.token }} + run: | + gh api \ + repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \ + --header "Accept: application/vnd.github.v3.diff" > pr.diff + + - name: Detect ai_playerbot_texts inserts + id: detect + run: | + if grep -E '^\+.*INSERT[[:space:]]+INTO[[:space:]]+`?ai_playerbot_texts`?' pr.diff; then + echo "has_translation=true" >> "$GITHUB_OUTPUT" + else + echo "has_translation=false" >> "$GITHUB_OUTPUT" + fi + + - name: Add label + if: steps.detect.outputs.has_translation == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + gh pr edit ${{ github.event.pull_request.number }} \ + --add-label "Added translation"