-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (50 loc) · 1.35 KB
/
python-isort-formatter.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
name: Python isort Formatter
on:
workflow_call:
inputs:
isort_command:
description: 'The isort command to run'
type: string
required: false
default: 'isort .'
jobs:
isort:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Sort imports
run: |
python -m pip install --upgrade pip
pip install isort
${{ github.event.inputs.isort_command }}
-
name: Remove unused imports
run: |
python -m pip install --upgrade pip
pip install autoflake
autoflake --in-place --remove-all-unused-imports --remove-unused-variables --recursive .
-
name: Check for changes
id: check_changes
run: |
if git diff --quiet; then
echo "No changes"
echo "changes=0" >> $GITHUB_ENV
else
echo "Changes found"
echo "changes=1" >> $GITHUB_ENV
fi
-
name: Push changes to GitHub
if: steps.check_changes.outputs.changes == '1'
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Apply isort and autoflake"
git push