File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 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 commit
34+ if : steps.changes.outputs.changed == 'true'
35+ shell : bash
36+ run : |
37+ git config --local user.email "[email protected] " 38+ git config --local user.name "GitHub Action"
39+ git add .pre-commit-config.yaml
40+ git commit -m "[pre-commit] Update hooks versions
41+
42+ Updates:
43+ $(grep "updating" autoupdate.log || echo "No updates found")
44+
45+ 🤖 Generated automatically by update-pre-commit workflow"
46+ - name : Push changes
47+ if : steps.changes.outputs.changed == 'true'
48+ shell : bash
49+ run : git push
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments