-
Notifications
You must be signed in to change notification settings - Fork 35
50 lines (41 loc) · 1.17 KB
/
lint-fix.yml
File metadata and controls
50 lines (41 loc) · 1.17 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
name: Lint Auto-fix
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: write
jobs:
lint-fix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install linters
run: |
python -m pip install black==23.12.1 isort==5.13.2
- name: Run black
run: black --line-length=120 .
- name: Run isort
run: isort --profile black .
- name: Check for changes
id: check
run: |
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit fixes
if: steps.check.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "style: auto-fix lint (black + isort)"
git push