Skip to content

Commit ffca772

Browse files
authored
GitHub Action formats our code with psf/black
@poyea Your review please.
1 parent 52cf668 commit ffca772

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

.github/workflows/autoblack.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
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 complient with Black then this Action does nothing.
3-
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
1+
# GitHub Action that uses Black to reformat Python code (if needed) when doing a git push.
2+
# If all Python code in the repo is complient with Black then this Action does nothing.
3+
# Otherwise, Black is run and its changes are committed to the repo.
44
# https://github.com/cclauss/autoblack
55

6-
name: autoblack
7-
on: [pull_request]
6+
name: autoblack_push
7+
on: [push]
88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11-
strategy:
12-
max-parallel: 1
13-
matrix:
14-
python-version: [3.7]
1511
steps:
1612
- uses: actions/checkout@v1
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v1
19-
with:
20-
python-version: ${{ matrix.python-version }}
21-
- name: Install psf/black
22-
run: pip install black
23-
- name: Run black --check .
24-
run: black --check .
25-
- name: If needed, commit black changes to the pull request
13+
- uses: actions/setup-python@v1
14+
- run: pip install black
15+
- run: black --check .
16+
- name: If needed, commit black changes to a new pull request
2617
if: failure()
2718
run: |
2819
black .
29-
git config --global user.name 'autoblack'
30-
git config --global user.email 'cclauss@users.noreply.github.com'
20+
git config --global user.name github-actions
21+
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
3122
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
32-
git checkout $GITHUB_HEAD_REF
33-
git commit -am "fixup: Format Python code with psf/black"
34-
git push
23+
git commit -am "fixup! Format Python code with psf/black push"
24+
git push --force origin HEAD:$GITHUB_REF

0 commit comments

Comments
 (0)