Skip to content

Commit 4c29214

Browse files
style/fix: fixed linter
1 parent bd52b4f commit 4c29214

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

.github/workflows/lint.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
name: Lint
2-
3-
on: [push, pull_request]
1+
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
2+
# If all Python code in the pull request is compliant with Black then this Action does nothing.
3+
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
4+
# https://github.com/cclauss/autoblack
45

6+
name: autoblack
7+
on: [pull_request, workflow_dispatch]
58
jobs:
6-
lint:
9+
build:
710
runs-on: ubuntu-latest
811
steps:
9-
- uses: actions/checkout@v2
10-
- uses: psf/black@stable
12+
- uses: actions/checkout@v1
13+
- name: Set up Python 3.7
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: 3.9
17+
- name: Install Black
18+
run: pip install black
19+
- name: Run black --check .
20+
run: black --check .
21+
- name: If needed, commit black changes to the pull request
22+
if: failure()
23+
run: |
24+
black . --line-length 101
25+
git config --global user.name 'autoblack'
26+
git config --global user.email 'cclauss@users.noreply.github.com'
27+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
28+
git checkout $GITHUB_HEAD_REF
29+
git commit -am "fixup: Format Python code with Black"
30+
git push

0 commit comments

Comments
 (0)