Main fix name #33
Workflow file for this run
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: Auto Format Python Code with Black | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install black | |
- name: Run Black | |
run: | | |
black . | |
- name: Check for changes | |
id: check_changes | |
run: | | |
git diff --exit-code || echo "Changes detected" | |
- name: Commit changes | |
if: steps.check_changes.outputs.exit_code != 0 | |
run: | | |
git config --local user.name "github-actions" | |
git config --local user.email "github-actions@github.com" | |
git add . | |
git commit -m "Format Python code with Black" || echo "No changes to commit" | |
git push |