-
Notifications
You must be signed in to change notification settings - Fork 4
43 lines (42 loc) · 1.42 KB
/
auto_blacken.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
name: auto-blacken
on: [push, pull_request]
jobs:
# job skipper in the case of concurrent push + pull_request trigger
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{steps.skip_check.outputs.should_skip}}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
do_not_skip: '["push"]'
# actual autoblacken
main_job:
name: runner / black
needs: pre_job
if: ${{needs.pre_job.outputs.should_skip != 'true'}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
- uses: actions/checkout@v2
if: github.event_name == 'push'
with:
fetch-depth: 0
- name: Check files using the black formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- name: Create commit on changes
if: steps.action_black.outputs.is_formatted == 'true'
run: |
git config --global user.name '${{github.actor}}'
git config --global user.email '${{github.actor}}@users.noreply.github.com'
git commit -am ":art: Format Python code with psf/black" -m "There appear to be some python formatting errors in ${{github.sha}}."
git push