mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
5df8aec66c
* GitHub Action formats our code with psf/black @poyea Your review please. * fixup! Format Python code with psf/black push
25 lines
1018 B
YAML
25 lines
1018 B
YAML
# 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@v1
|
|
- 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
|