Skip to content

Commit

Permalink
Merge pull request AXERA-TECH#2 from kalcohol/main-add-format
Browse files Browse the repository at this point in the history
add format actions
  • Loading branch information
kalcohol authored Dec 5, 2024
2 parents 48a7dd6 + c1238d4 commit daa308d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/auto_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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 "[email protected]"
git add .
git commit -m "Format Python code with Black" || echo "No changes to commit"
git push

0 comments on commit daa308d

Please sign in to comment.