name: php-cs-fixer

on:
  push:
    branches:
      - "master"
    paths:
      - '**.php'

jobs:
  php-cs-fixer:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'

      - run: "composer install --no-interaction --no-progress --no-suggest"

      - name: "Run friendsofphp/php-cs-fixer"
        run: "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose"

      - name: "Commit modified files"
        uses: "stefanzweifel/git-auto-commit-action@v2.5.0"
        with:
          branch: "master"
          commit_message: "Apply php-cs-fixer changes"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
