-
Notifications
You must be signed in to change notification settings - Fork 7
47 lines (38 loc) · 1.03 KB
/
auto_format_python.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
name: Auto Format Python Code with Black
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
- name: Run Black
run: |
black .
- name: Commit changes
id: commit_changes
uses: stefanzweifel/git-auto-commit-action@v5
- name: "Run if changes have been detected"
if: steps.commit_changes.outputs.changes_detected == 'true'
run: echo "Code formated."
- name: "Run if no changes have been detected"
if: steps.commit_changes.outputs.changes_detected == 'false'
run: echo "No Changes."