-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (44 loc) · 1.28 KB
/
Copy pathformatter.yml
File metadata and controls
55 lines (44 loc) · 1.28 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
52
53
54
name: Python Lint and Format
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install Tools
run: |
pip install black flake8 isort
- name: Format Code with Black
run: black .
- name: Lint Code with Flake8
run: |
echo "[flake8]" > .flake8
echo "max-line-length = 120" >> .flake8
flake8 .
rm -f .flake8
- name: Auto-fix imports with isort
run: isort .
- name: Push changes
if: ${{ github.ref == 'refs/heads/main' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
# Check if there are any changes to commit
git add .
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "Auto-fix: Code formatting and imports sorted"
git push origin main
fi