-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (47 loc) · 1.57 KB
/
update_pre-commit_hooks.yml
File metadata and controls
51 lines (47 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Update pre-commit Hooks
on:
schedule:
- cron: "0 0 * * 5"
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.PAT_FOR_PUSHES }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install poetry
run: pip install poetry
- name: Cache dependencies
uses: actions/cache@v5
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
# Update pre-commit hooks and check for changes
- name: Update pre-commit hooks
id: update_hooks
run: |
poetry run pre-commit autoupdate
if git diff --exit-code .pre-commit-config.yaml; then
echo "has_updates=false" >> "$GITHUB_OUTPUT"
echo "No updates to pre-commit hooks. Exiting workflow."
else
echo "has_updates=true" >> "$GITHUB_OUTPUT"
fi
# Commit/push
- name: Commit changes
if: steps.update_hooks.outputs.has_updates == 'true'
shell: bash
run: |
git config --local user.email "33836132+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .pre-commit-config.yaml
git commit -m ":arrow_up: Update pre-commit hooks [skip ci]" || echo "No changes to commit"
git push