name: normalize composer.json

on:
  push:
    paths:
      - 'composer.json'

jobs:
  normalize:
    timeout-minutes: 1
    runs-on: ubuntu-latest
    steps:
      - name: Git checkout
        uses: actions/checkout@v3

      - name: Validate Composer configuration
        run: composer validate --strict

      - name: Normalize composer.json
        run: |
          composer global require ergebnis/composer-normalize
          composer normalize --indent-style=space --indent-size=4 --no-check-lock --no-update-lock --no-interaction --ansi

      - uses: stefanzweifel/git-auto-commit-action@v4.14.1
        with:
          commit_message: normalize composer.json
