-
-
Notifications
You must be signed in to change notification settings - Fork 4
47 lines (45 loc) · 1.44 KB
/
black.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Black
on:
pull_request:
push:
workflow_dispatch:
jobs:
build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == true
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.11" ]
steps:
- if: github.event_name != 'pull_request'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .[dev]
- name: Formatting the code with Black
run: |
black $(git ls-files '*.py')
- name: Git config
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Git diff
run: |
git diff HEAD || true
- name: Git add
run: |
git add *
- name: Git commit & push
run: |
git diff-index --quiet HEAD || ( git commit -m "Format \"$(git show -s --format=%s)\" using Black" && git push )