From 237f2942acb492a717eb885d0377271e7e15abd4 Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Tue, 12 Dec 2023 11:59:55 -0300 Subject: [PATCH] try to handle grep exit gracefully --- .github/workflows/add-strict-types.yml | 32 ++++++++++---------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/add-strict-types.yml b/.github/workflows/add-strict-types.yml index b3ef823747..f6edca4641 100644 --- a/.github/workflows/add-strict-types.yml +++ b/.github/workflows/add-strict-types.yml @@ -18,39 +18,31 @@ jobs: with: php-version: '8.1' - - name: Check for new PHP files - id: check + - name: Add strict types to new PHP files + id: add_strict_types run: | - git fetch origin +refs/heads/trunk:refs/remotes/origin/trunk - NEW_PHP_FILES=$(git diff --name-only refs/remotes/origin/trunk HEAD -- '*.php' | xargs -r grep -LE 'declare\( strict_types=1 \)') + git fetch origin +refs/heads/trunk:refs/remotes/origin/trunk --quiet + NEW_PHP_FILES=$(git diff --name-only refs/remotes/origin/trunk HEAD -- '*.php' | xargs -r grep -LE 'declare\( strict_types=1 \)' || true) if [ -n "$NEW_PHP_FILES" ]; then + echo "$NEW_PHP_FILES" | xargs -I {} sed -i '1s|^|