name: Auto-fix
on:
  push:
  pull_request:
jobs:
  style:
    runs-on: ubuntu-latest
    steps:
      - name: Download source
        uses: actions/checkout@v4
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Install Hatch
        run: |
          pip install hatch
      - name: Install dependencies
        run: |
          hatch run style:pip freeze
      - name: Fix code style
        run: |
          hatch run style:fix --fix-only
      - name: Check if any edits are necessary
        run: |
          git diff --color --exit-code
      - name: Apply automatic fixes using pre-commit-ci-lite
        if: failure() && github.event_name == 'pull_request'
        uses: pre-commit-ci/lite-action@v1.0.1
