-
Notifications
You must be signed in to change notification settings - Fork 24
41 lines (33 loc) · 1.05 KB
/
format.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
# Uses Black to reformat the Python code on the all but the main branch.
name: Format
on:
push:
branches:
- '**' # matches every branch
- '!main' # excludes master
permissions:
contents: write
jobs:
format:
runs-on: ubuntu-latest
steps:
# Checkout the main branch
- uses: actions/checkout@v3
# Setup Python environment
- uses: actions/setup-python@v3
# Install black
- name: Install black
run: pip install black
# Execute black in check mode
- name: Black
id: black
run: echo ::set-output name=format::$(black --check --quiet . || echo "true")
# Execute black and commit the change to the main branch
- name: Commit to the main branch
if: steps.black.outputs.format == 'true'
run: |
black .
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git commit -am "[github-action] formatting fixes"
git push