Skip to content

Daily Pre-commit Autoupdate #225

Daily Pre-commit Autoupdate

Daily Pre-commit Autoupdate #225

name: Daily Pre-commit Autoupdate
on:
schedule:
- cron: "0 0 * * *"
pull_request:
branches:
- main
paths:
- .github/workflows/precommit_updates.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit autoupdate
id: auto_update
run: |
pre-commit autoupdate
files_changed_count="$(git diff --name-only | wc -l)"
echo "files_changed_count=$files_changed_count" >> "$GITHUB_OUTPUT"
- name: Commit changes
if: ${{ steps.auto_update.outputs.files_changed_count != '0' }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Auto-update pre-commit hooks"
- name: Create pull request
if: ${{ steps.auto_update.outputs.files_changed_count != '0' }}
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Auto-update pre-commit hooks"
branch: auto-update-pre-commit-hooks
title: "Auto-update pre-commit hooks"
body: "This pull request was automatically generated to update the pre-commit hooks."
base: main