feat(ci): add GitHub Actions workflow for code formatting with Black #1
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: Black Formatter | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install Black | |
run: pip install black | |
- name: Run Black | |
id: black | |
run: | | |
black --check . | |
continue-on-error: true | |
- name: Commit changes | |
if: steps.black.outcome == 'failure' | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
black . | |
git add . | |
git commit -m "style: format code with Black" | |
git push |