Skip to content

Commit 39f122c

Browse files
committed
[CI] Add GHA to update pre-commit dependencies
1 parent caec770 commit 39f122c

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Update Pre-commit Hooks'
2+
description: 'Updates pre-commit hook versions and creates a PR if changes are detected'
3+
inputs:
4+
python-version:
5+
description: 'Python version to use'
6+
required: false
7+
default: '3.13'
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
- name: Install pre-commit
17+
shell: bash
18+
run: pip install pre-commit
19+
- name: Update pre-commit hooks
20+
shell: bash
21+
run: |
22+
pre-commit autoupdate > autoupdate.log 2>&1
23+
cat autoupdate.log
24+
- name: Check for changes
25+
id: changes
26+
shell: bash
27+
run: |
28+
if git diff --quiet .pre-commit-config.yaml; then
29+
echo "changed=false" >> $GITHUB_OUTPUT
30+
else
31+
echo "changed=true" >> $GITHUB_OUTPUT
32+
fi
33+
- name: Create Pull Request
34+
if: steps.changes.outputs.changed == 'true'
35+
uses: peter-evans/create-pull-request@v7
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
commit-message: "[pre-commit] Update hooks versions"
39+
title: "[pre-commit] Update hooks versions"
40+
body: |
41+
This PR updates the pre-commit hook versions to their latest releases.
42+
43+
Updates:
44+
```
45+
$(grep "updating" autoupdate.log || echo "No updates found")
46+
```
47+
48+
🤖 This PR was created automatically by the update-pre-commit workflow.
49+
branch: update-pre-commit-hooks
50+
base: master
51+
delete-branch: true
52+
labels: |
53+
dependencies
54+
automated
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Update pre-commit hooks
2+
3+
on:
4+
pull_request: # TODO: remove
5+
schedule:
6+
- cron: '0 0 * * *'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
actions: write
13+
checks: write
14+
repository-projects: write
15+
16+
jobs:
17+
update-pre-commit:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
- name: Update pre-commit hooks
23+
uses: ./.github/actions/update-precommit

0 commit comments

Comments
 (0)