Skip to content

Commit 375c3e7

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

File tree

2 files changed

+81
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)