chore: 新增 pre-commit action #155
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code formatter | |
on: [push, pull_request] | |
jobs: | |
formatter: | |
name: Code formatter | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "*" | |
- run: pip install black isort | |
- name: Format code with black and isort | |
run: | | |
isort . | |
black . | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
author_name: ${{ github.actor }} | |
author_email: ${{ github.actor }}@users.noreply.github.com | |
message: "style: Format code with black and isort" | |
add: "." | |
- name: Push changes | |
run: git push origin HEAD:${{ github.head_ref }} |