forked from cclauss/autoblack
-
Notifications
You must be signed in to change notification settings - Fork 0
27 lines (25 loc) · 1.14 KB
/
autoblack_push.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
# GitHub Action that uses Black to reformat Python code (if needed) when doing a git push.
# If all Python code in the repo is complient with Black then this Action does nothing.
# Otherwise, Black is run and its changes are committed to the repo.
# https://github.com/cclauss/autoblack
name: autoblack_push
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with: # https://github.com/stefanzweifel/git-auto-commit-action#checkout-the-correct-branch
ref: ${{ github.head_ref }}
- uses: actions/setup-python@v1
- run: pip install black
- run: black --check .
- name: If needed, commit black changes to a new pull request
if: failure()
run: |
black .
git config --global user.name github-actions
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
# git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git commit -am "fixup! Format Python code with psf/black push"
git push # --force origin HEAD:$GITHUB_REF