forked from dracoventions/TWCManager
-
Notifications
You must be signed in to change notification settings - Fork 55
46 lines (42 loc) · 1.49 KB
/
autoblack.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
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
# If all Python code in the pull request is compliant with Black then this Action does nothing.
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
# https://github.com/cclauss/autoblack
name: Automatically format sources
defaults:
run:
working-directory: ./black
on:
push:
branches:
- 'ci_dev'
- 'main'
jobs:
build:
name: Format Sources
# Temporary while self-hosted infra is down
# runs-on: [ "self-hosted", "build_host" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: ./black
ref: ${{ github.event.push.head.sha }}
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install Black
run: pip install black
- name: Check if formatting is required for any file
run: black --exclude="setup.py|tests/*" --check .
- name: If needed, commit black changes to the repo
if: failure()
run: |
black --exclude="setup.py|tests/*" .
git config --global user.name 'Auto Format'
git config --global user.email 'ngardiner@gmail.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git checkout
git commit -am "fixup: Format Python code with Black"
git push