You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
3 years ago
|
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
|
||
|
# If all Python code in the pull request is compliant with Black then this Action does nothing.
|
||
|
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
|
||
|
# https://github.com/cclauss/autoblack
|
||
|
|
||
7 months ago
|
name: fmt
|
||
3 years ago
|
on:
|
||
|
push:
|
||
2 years ago
|
branches: ["develop"]
|
||
3 years ago
|
jobs:
|
||
|
build:
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
7 months ago
|
- uses: actions/checkout@v4
|
||
|
- name: Set up Python 3.10
|
||
|
uses: actions/setup-python@v5
|
||
3 years ago
|
with:
|
||
7 months ago
|
python-version: 3.10.14
|
||
3 years ago
|
- name: Install Black
|
||
|
run: pip install black
|
||
|
- name: Run black --check .
|
||
|
run: black --check .
|
||
|
- name: If needed, commit black changes to the pull request
|
||
|
if: failure()
|
||
|
run: |
|
||
|
black . --line-length 101
|
||
2 years ago
|
git config --global user.name github-actions
|
||
|
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||
3 years ago
|
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
||
|
git checkout $GITHUB_HEAD_REF
|
||
|
git commit -am "fixup: Format Python code with Black"
|
||
2 years ago
|
git push origin HEAD:develop
|
||
7 months ago
|
|
||
|
- uses: isort/isort-action@v1
|
||
|
with:
|
||
7 months ago
|
requirements-files: "requirements.txt"
|
||
7 months ago
|
|
||
|
|
||
|
|