Skip to content

Commit

Permalink
Avoid opening multiple PRs for pre-commit updates
Browse files Browse the repository at this point in the history
This moves pre-commit updates to a github action that runs monthly.
This has the advantage of including *all* updates in a single PR.
  • Loading branch information
mike8699 committed Oct 1, 2023
1 parent 2d9111e commit a7c655e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: pre-commit autoupdate

on:
schedule:
- cron: 0 0 1 * * # first day of the month
workflow_dispatch:

jobs:
pre-commit-autoupdate:
name: Update pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: '.python-version'
check-latest: true

- name: Upgrade `pip`
run: python -m pip install --upgrade pip

- name: Install pre-commit
run: pip install pre-commit

- name: Update pre-commit hooks
run: pre-commit autoupdate

- name: Open a pull request
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
add-paths: .pre-commit-config.yaml
commit-message: '[pre-commit] automatic update'
title: '[pre-commit] automatic update'
body: ''

- name: Enable pull request automerge
if: steps.create-pr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}
merge-method: squash
4 changes: 0 additions & 4 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
"extends": [
"config:base"
],
"pre-commit": {
"enabled": true
},
"packageRules": [
{
"matchFileNames": [
".pre-commit-config.yaml",
".github/workflows/**"
],
"automerge": true,
Expand Down

0 comments on commit a7c655e

Please sign in to comment.