From cadabff925cb6e9c2a38b74974680066b7aa889e Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Mon, 18 Nov 2024 10:30:17 -0800 Subject: [PATCH] Run PHPCBF to auto-fix and commit where possible I.e. don't fail a PR if the computer can fix it --- .github/workflows/lint.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8c01fd5..a9f738e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,7 +39,6 @@ jobs: - name: Get Composer cache directory id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - if: "!! env.GIT_DIFF" - name: Cache Composer vendor directory uses: actions/cache@v4 @@ -48,15 +47,25 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-composer- - if: "!! env.GIT_DIFF" - name: Validate composer.json and composer.lock run: composer validate - if: "!! env.GIT_DIFF" - name: Install dependencies run: composer install --no-progress --optimize-autoloader --prefer-dist - if: "!! env.GIT_DIFF" + + - name: Fix auto-fixable PHP Code Standards Violations + continue-on-error: true + run: vendor/bin/phpcbf --standard=phpcs.xml + + - name: Commit PHPCBF changes on main + if: ${{ github.ref == 'refs/heads/main' }} # only commit on main + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "🤖 PHPCBF" + commit_options: "" + env: + GITHUB_TOKEN: "${{ github.token }}" - name: Detecting PHP Code Standards Violations run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF }} --report=checkstyle | cs2pr