-
Notifications
You must be signed in to change notification settings - Fork 11
32 lines (32 loc) · 1.15 KB
/
formatting.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
27
28
29
30
31
32
name: Black
on: pull_request
jobs:
formatting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} for Black
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Black
run: pip install black
- name: Check Formatting
run: black --check . # Only check the formatting, don't make any changes
- name: Apply Formatting
if: failure() # Only run if Black suggests changes
run: |
black .
git config --global user.name "BlackBot"
git config --global author.name "BlackBot"
git config --global user.email "[email protected]"
git config --global author.email "[email protected]"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git fetch origin
git checkout $GITHUB_HEAD_REF
git pull
git commit -am "Apply Black formatting to Python code."
git push