name: pre-commit autoupdate

permissions:
  pull-requests: write
  contents: write

on:
  schedule:
    - cron: 0 3 1 1/6 *
  workflow_dispatch:

jobs:
  autoupdate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install pre-commit
        run: pip install pre-commit
      - name: Run pre-commit autoupdate
        run: pre-commit autoupdate
      - name: Open pull request
        uses: peter-evans/create-pull-request@v6.1.0
        with:
          branch: pre-commit-autoupdate
          title: Upgrade pre-commit hooks revisions
          commit-message: Upgrade pre-commit hooks revisions
          body: "Upgrades revisions of pre-commit hooks tools to latest versions :hammer_and_wrench:"
          labels: dependencies
          delete-branch: true
