[pull] main from yeonholee50:main #2
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: Pre-Commit Linting | |
on: | |
push: | |
branches: ['**'] # Runs on all branches when pushing | |
pull_request: | |
branches: ['**'] # Runs on all PRs | |
types: [opened, synchronize] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Get full history for better diffs | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install pre-commit and dependencies | |
run: | | |
pip install pre-commit black==25.1.0 isort==6.0.1 flake8==7.1.2 | |
- name: Run pre-commit hooks | |
run: pre-commit run --all-files | |
# Add these steps to auto-commit formatting changes | |
- name: Commit changes | |
if: github.event_name == 'push' | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add -A | |
git diff --quiet && git diff --staged --quiet || git commit -m "Auto-format code with pre-commit hooks" | |
- name: Push changes | |
if: github.event_name == 'push' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |