Skip to content

Commit a4c64b0

Browse files
authored
Autoformat when pushed directly (#79)
* Create push_format.yml * remove unused
1 parent bfe974e commit a4c64b0

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/push_format.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: push format
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
push_format:
10+
permissions:
11+
actions: write
12+
checks: write
13+
contents: write
14+
issues: write
15+
repository-projects: write
16+
pull-requests: write
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
ref: ${{github.ref_name}}
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install Black
29+
run: pip install black
30+
31+
- name: Run Black
32+
# run: black $(git ls-files '*.py')
33+
run: black .
34+
35+
- name: Commit Back
36+
continue-on-error: true
37+
id: commitback
38+
run: |
39+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
40+
git config --local user.name "github-actions[bot]"
41+
git add --all
42+
git commit -m "Format code"
43+
44+
- name: Create Pull Request
45+
if: steps.commitback.outcome == 'success'
46+
continue-on-error: true
47+
uses: peter-evans/create-pull-request@v4
48+
with:
49+
body: Apply Code Formatter Change
50+
commit-message: Automatic code format

0 commit comments

Comments
 (0)