---
# $schema: "https://json.schemastore.org/github-workflow.json"
name: Pre-commit autoupdate

on:
  schedule:
    # At 04:00 on Monday and Thursday.
    - cron: '0 4 * * 1,4'
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions: read-all

jobs:
  auto-update:
    runs-on: self-hosted

    permissions:
      contents: write
      pull-requests: write

    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

      - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0

      - run: pip install pre-commit && pre-commit autoupdate

      - uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: update/pre-commit-hooks
          title: 'chore: update pre-commit hooks'
          commit-message: 'chore: update pre-commit hooks'
          body: Update versions of pre-commit hooks to latest version.
