-
-
Notifications
You must be signed in to change notification settings - Fork 156
47 lines (46 loc) · 1.41 KB
/
pre-commit-fix.yaml
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
name: Pre-commit fix
on:
workflow_dispatch:
permissions:
contents: write
jobs:
run-pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install pre-commit
run: |
python -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install pre-commit
- name: Run pre-commit
run: |
. venv/bin/activate
pre-commit run --all-files
continue-on-error: true
- name: Check for changes
id: check_changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Changes detected by pre-commit."
echo "::set-output name=changes_detected::true"
else
echo "No changes made by pre-commit."
echo "::set-output name=changes_detected::false"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changes_detected == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Apply pre-commit fixes"
git push origin HEAD:${{ github.ref_name }}