File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 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
5+
6+ name : autoblack
7+ on : [pull_request]
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v1
13+ - name : Set up Python 3.9
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 .
25+ git config --global user.name 'autoblack'
26+ git config --global user.email '[email protected] ' 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
You can’t perform that action at this time.
0 commit comments