-
-
Notifications
You must be signed in to change notification settings - Fork 13
53 lines (46 loc) · 1.69 KB
/
indent_check.yml
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
52
53
name: Python Indentation Check and Pull Request
on:
push:
branches:
- main # Change this to your main branch name if different
jobs:
indent_check_and_pr:
name: Indentation Check and Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Replace with the version of Python used in your repository
- name: Install flake8 and black
run: |
pip install flake8 black
- name: Run flake8 for Indentation Errors
id: check_indentation
run: |
if flake8 --select=E --show-source --quiet .; then
echo "No indentation errors found."
else
echo "Indentation errors found. Fixing the errors..."
black .
git add .
fi
- name: Commit and push changes
if: steps.check_indentation.outputs.result == 'failure'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Fix Python indentation errors" || true
git push origin HEAD
- name: Create Pull Request
if: steps.check_indentation.outputs.result == 'failure'
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Fix Python indentation errors"
title: "Fix Python indentation errors"
body: "This pull request fixes Python indentation errors identified by flake8."
base: main
branch: fix-indentation-errors