Skip to content

Commit

Permalink
Run PHPCBF to auto-fix and commit where possible
Browse files Browse the repository at this point in the history
I.e. don't fail a PR if the computer can fix it
  • Loading branch information
BrianHenryIE committed Nov 18, 2024
1 parent 7a50a91 commit cadabff
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit cadabff

Please sign in to comment.