Skip to content

Commit b5e9e86

Browse files
committed
Make GitHub Actions keep our pre-commit hooks up to date
1 parent 48b4880 commit b5e9e86

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright (c) 2025 Sebastian Pipping <[email protected]>
2+
# Licensed under GNU Affero GPL v3 or later
3+
4+
name: Detect outdated pre-commit hooks
5+
6+
on:
7+
schedule:
8+
- cron: '0 2 * * 5' # Every Friday at 2am
9+
workflow_dispatch:
10+
11+
# NOTE: This will drop all permissions from GITHUB_TOKEN except metadata read,
12+
# and then (re)add the ones listed below:
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
pre_commit_detect_outdated:
19+
name: Detect outdated pre-commit hooks
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
23+
24+
- name: Set up Python 3.13
25+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
26+
with:
27+
python-version: 3.13
28+
29+
- name: Install pre-commit
30+
run: |-
31+
pip install \
32+
--disable-pip-version-check \
33+
--no-warn-script-location \
34+
--user \
35+
pre-commit
36+
echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}"
37+
38+
- name: Check for outdated hooks
39+
run: |-
40+
pre-commit autoupdate
41+
git diff -- .pre-commit-config.yaml
42+
43+
- name: Create pull request from changes (if any)
44+
id: create-pull-request
45+
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
46+
with:
47+
author: 'pre-commit <[email protected]>'
48+
base: main
49+
body: |-
50+
For your consideration.
51+
52+
:warning: Please **CLOSE AND RE-OPEN** this pull request so that [further workflow runs get triggered](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs) for this pull request.
53+
branch: precommit-autoupdate
54+
commit-message: "pre-commit: Autoupdate"
55+
delete-branch: true
56+
draft: true
57+
labels: enhancement
58+
title: "pre-commit: Autoupdate"
59+
60+
- name: Log pull request URL
61+
if: "${{ steps.create-pull-request.outputs.pull-request-url }}"
62+
run: |
63+
echo "Pull request URL is: ${{ steps.create-pull-request.outputs.pull-request-url }}"

0 commit comments

Comments
 (0)