-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (36 loc) · 1.08 KB
/
format-code.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
name: Format Code
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.repository }}
token: ${{ github.token }}
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Setup dependencies
run: |
pip install --upgrade yapf==0.30.0 isort
- name: Format code
run: |
yapf --verbose --recursive --in-place --parallel .
isort .
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add .
git commit -am "Format code."
git push