diff --git a/.github/workflows/add-strict-types.yml b/.github/workflows/add-strict-types.yml index 713ce2dbe4..253fd8b243 100644 --- a/.github/workflows/add-strict-types.yml +++ b/.github/workflows/add-strict-types.yml @@ -18,42 +18,44 @@ jobs: with: php-version: '8.1' - - name: Checking for new PHP files + - name: Check for new PHP files id: check run: | - if [[ $(git rev-parse --verify HEAD^) ]]; then - if [[ $(git diff --name-only HEAD^ HEAD | grep -E "\.php$" | xargs grep -L "declare\(strict_types=1\)" | wc -l) -gt 0 ]]; then - echo "::set-output name=strict_types::false" - else - echo "::set-output name=strict_types::true" - fi + git fetch origin trunk + NEW_PHP_FILES=$(git diff --name-only origin/trunk...HEAD -- '*.php' | xargs grep -LE 'declare\( strict_types=1\ )') + if [ -n "$NEW_PHP_FILES" ]; then + echo "::set-output name=strict_types_needed::true" + echo "New PHP files without strict types: $NEW_PHP_FILES" else - echo "::set-output name=strict_types::true" + echo "::set-output name=strict_types_needed::false" fi - - - name: Add strict types - if: steps.check.outputs.strict_types == 'false' - run: | - git diff --name-only HEAD^ HEAD | grep -E "\.php$" | xargs sed -i '1s/^/