File tree 1 file changed +37
-21
lines changed
1 file changed +37
-21
lines changed Original file line number Diff line number Diff line change 1
- name : black-action
2
- on : [push, pull_request]
1
+ name : Formatting
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+
3
8
jobs :
4
- linter_name :
5
- name : runner / black
9
+ format :
6
10
runs-on : ubuntu-latest
11
+
7
12
steps :
8
- - uses : actions/checkout@v2
9
- - name : Check files using the black formatter
10
- uses : rickstaa/action-black@v1
11
- id : action_black
13
+ - name : Checkout code
14
+ uses : actions/checkout@v2
15
+
16
+ - name : Set up Python
17
+ uses : actions/setup-python@v2
12
18
with :
13
- black_args : " ."
14
- - name : Create Pull Request
15
- if : steps.action_black.outputs.is_formatted == 'true'
16
- uses : peter-evans/create-pull-request@v3
17
- with :
18
- token : ${{ secrets.GH_TOKEN }}
19
- title : " Format Python code with psf/black push"
20
- commit-message : " :art: Format Python code with psf/black"
21
- body : |
22
- There appear to be some python formatting errors in ${{ github.sha }}. This pull request
23
- uses the [psf/black](https://github.com/psf/black) formatter to fix these issues.
24
- base : ${{ github.head_ref }} # Creates pull request onto pull request or commit branch
25
- branch : actions/black
19
+ python-version : ' 3.x'
20
+
21
+ - name : Install black
22
+ run : pip install black
23
+
24
+ - name : Run black
25
+ run : |
26
+ black .
27
+
28
+ - name : Commit changes
29
+ run : |
30
+ git config --global user.email "[email protected] "
31
+ git config --global user.name "GitHub Actions"
32
+ git config --global credential.helper "store --file=.git-credentials"
33
+ echo "https://github.com/${GITHUB_REPOSITORY}.git" > .git-credentials
34
+ git add .
35
+ git diff-index --quiet HEAD || git commit -m "Auto-format code with Black"
36
+ git push https://[email protected] /${GITHUB_REPOSITORY}.git HEAD:$GITHUB_REF
37
+
38
+
39
+
40
+
41
+
You can’t perform that action at this time.
0 commit comments