-
Notifications
You must be signed in to change notification settings - Fork 32
40 lines (33 loc) · 1017 Bytes
/
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
name: Black Linter
# This allows Black be called from the isort workflow
on:
workflow_call:
jobs:
black-linter:
name: Run Black
runs-on: ubuntu-latest
steps:
- name: Determine Branch Name
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
else
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH_NAME }}
- name: Pull latest changes
run: git pull origin ${{ env.BRANCH_NAME }}
- name: Run Black formatter
uses: psf/black@stable
with:
options: "--verbose"
src: "."
jupyter: true
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply black formatting changes