Update pre-commit Hooks #52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update pre-commit Hooks | |
| on: | |
| schedule: | |
| - cron: "0 0 * * 5" | |
| workflow_dispatch: | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT_FOR_PUSHES }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Install poetry | |
| run: pip install poetry | |
| - name: Cache dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pypoetry | |
| key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
| - name: Install dependencies | |
| run: poetry install | |
| # Update pre-commit hooks and check for changes | |
| - name: Update pre-commit hooks | |
| id: update_hooks | |
| run: | | |
| poetry run pre-commit autoupdate | |
| if git diff --exit-code .pre-commit-config.yaml; then | |
| echo "has_updates=false" >> "$GITHUB_OUTPUT" | |
| echo "No updates to pre-commit hooks. Exiting workflow." | |
| else | |
| echo "has_updates=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Commit/push | |
| - name: Commit changes | |
| if: steps.update_hooks.outputs.has_updates == 'true' | |
| shell: bash | |
| run: | | |
| git config --local user.email "33836132+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add .pre-commit-config.yaml | |
| git commit -m ":arrow_up: Update pre-commit hooks [skip ci]" || echo "No changes to commit" | |
| git push |