Skip to content

Commit 1598ed9

Browse files
authored
Create code_formatter.yml
1 parent 863a8c1 commit 1598ed9

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/code_formatter.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Code Formatter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
push_format:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
ref: ${{github.ref_name}}
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install Black and autoflake
27+
run: pip install "black[jupyter]" autoflake
28+
29+
- name: Run autoflake
30+
run: autoflake --in-place --recursive .
31+
32+
- name: Run Black
33+
run: black . --exclude=".*\.ipynb$"
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 "chore(format): run black on ${{github.ref_name}}"
43+
44+
- name: Create Pull Request
45+
if: steps.commitback.outcome == 'success'
46+
continue-on-error: true
47+
uses: peter-evans/create-pull-request@v5
48+
with:
49+
delete-branch: true
50+
body: "Automatically apply code formatter change"
51+
title: "chore(format): run black on ${{github.ref_name}}"
52+
commit-message: "chore(format): run black on ${{github.ref_name}}"
53+
branch: formatter/${{github.ref_name}}

0 commit comments

Comments
 (0)