durandtibo/objectory

View on GitHub
.github/workflows/pre-commit-autoupdate.yaml

Summary

Maintainability
Test Coverage
name: pre-commit auto-update

on:
  schedule:
    - cron: "0 8 * * 2" # run every Tuesday at 8:00 AM UTC
  workflow_call:
  workflow_dispatch:  # to trigger manually

permissions:
  contents: write
  pull-requests: write

jobs:
  auto-update:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: 3.12

      - name: Install Poetry
        uses: snok/install-poetry@v1

      - name: Set environment variable
        run: |
          echo $(poetry run poetry env info --path)/bin >> $GITHUB_PATH

      - name: Install packages
        run: |
          make config-poetry
          make install

      - name: Autoupdate pre-commit hooks
        run: |
          pre-commit autoupdate

      - name: Run pre-commit hooks
        run: |
          pre-commit run --all-files

      - uses: peter-evans/create-pull-request@v7
        if: always()
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: update/pre-commit-hooks
          title: Update pre-commit hooks
          commit-message: "Update pre-commit hooks"
          body: Update versions of pre-commit hooks to latest version.
          author: ci-bot <${{secrets.CI_BOT_EMAIL}}>