name: pre-commit

on:
  pull_request:
  push:
    branches:
    - master
  # Allow to run this workflow manually from the Actions tab
  workflow_dispatch:

env:
  FORCE_COLOR: 1

jobs:
  pre-commit:
    permissions:
      contents: read
      pull-requests: write
    name: linting
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v5
    - uses: actions/setup-python@v6
      with:
        python-version: 3.x
    - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd  #v3.0.1
      with:
        extra_args: --all-files --show-diff-on-failure
      env:
        PRE_COMMIT_COLOR: always
    - uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43  #v1.1.0
      if: always()
      with:
        msg: Apply pre-commit code formatting
