pre-commit auto-update #10
This file contains 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
# based on https://github.com/cookiecutter/cookiecutter-django/blob/master/ | |
# .github/workflows/pre-commit-autoupdate.yml | |
# run pre-commit autoupdate and create a pull request if any changes | |
name: pre-commit auto-update | |
on: | |
schedule: | |
- cron: "0 6 * * 1" # every Monday at 06:00 UTC | |
workflow_dispatch: # to trigger manually | |
permissions: | |
contents: read | |
jobs: | |
auto-update: | |
# disables this workflow from running in a repository that is not part of | |
# the indicated organization/user | |
if: github.repository_owner == 'martibosch' | |
permissions: | |
contents: write # for peter-evans/create-pull-request to create branch | |
pull-requests: write # for peter-evans/create-pull-request to create PR | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: install pre-commit | |
run: pip install pre-commit | |
- name: autoupdate template | |
run: pre-commit autoupdate | |
- name: autoupdate generated projects | |
working-directory: "{{ cookiecutter.repo_name }}" | |
run: pre-commit autoupdate | |
- name: create pull request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: update/pre-commit-autoupdate | |
title: auto-update pre-commit hooks | |
commit-message: "build: auto-update pre-commit hooks" | |
body: update to latest versions in pre-commit configs | |
labels: update |