Skip to content

Commit 5c1ec65

Browse files
authored
create auto black pipeline
1 parent 3f3c7b9 commit 5c1ec65

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/auto-black.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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, push]
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Set up Python 3.7
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: 3.8
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 '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)