# SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-2.0-or-later
name: QML Label component check
on:
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: QML Label component check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
      - name: Run label component count
        run: |
          MATCHESRESULT=$(find . -iname "*.qml" | xargs grep -r -e "^\s*Label\s*[{]" | wc -l | sed "s/ //g")
          echo "MATCHES=${MATCHESRESULT}" >> $GITHUB_ENV
          echo "EXPECTED_MATCHES=1" >> $GITHUB_ENV
      - name: Check label component use count
        if: env.MATCHES != env.EXPECTED_MATCHES
        uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
        with:
          script: |
              core.setFailed('Using QML Labels! Make sure to use EnforcedPlainTextLabel instead!')
