-
Notifications
You must be signed in to change notification settings - Fork 5
45 lines (37 loc) · 1016 Bytes
/
black.yaml
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
name: Black Formatter
on:
pull_request:
branches:
- master
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # Check out the PR branch
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Black
run: pip install black
- name: Run Black
run: black .
- name: Check for changes
id: changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes_detected=true" >> $GITHUB_ENV
else
echo "changes_detected=false" >> $GITHUB_ENV
fi
- name: Commit changes
if: env.changes_detected == 'true'
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: \`black .\`"
git push