name: Check & fix styling

on: push

jobs:
  php-cs-fixer:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.0
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
          coverage: none

      - name: Composer install
        run: composer install

      - name: Run php-cs-fixer
        run: ./vendor/bin/php-cs-fixer fix

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Apply php-cs-fixer changes
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
