Skip to content

Lint and Auto-fix Code #2

Lint and Auto-fix Code

Lint and Auto-fix Code #2

Workflow file for this run

name: Lint and Auto-fix Code
on:
push:
branches:
- main # Run on pushes to the main branch (you can specify other branches as needed)
pull_request:
branches:
- main # Optionally run on pull requests targeting the main branch
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x' # Specify the Python version you're using
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black isort
- name: Run Black (Auto-fix)
run: |
black .
- name: Run Isort (Auto-fix)
run: |
isort .
- name: Commit changes if any
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff-index --quiet HEAD || git commit -m "Auto-format: black and isort" || echo "No changes to commit"
- name: Push changes back to repository
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}