Skip to content

fix: pre-commit에 isort, flake8 추가 #74

fix: pre-commit에 isort, flake8 추가

fix: pre-commit에 isort, flake8 추가 #74

Workflow file for this run

name: Pre-commit Auto-fix and Comment
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
pre-commit:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pre-commit
run: python -m pip install --upgrade pre-commit
- name: Run pre-commit (auto-fix)
id: precommit_run
continue-on-error: true
run: |
pre-commit run --all-files --verbose --hook-stage manual
- name: Commit & push if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --quiet; then
git add -u
git commit -m "style: apply pre-commit fixes (black, isort)" || true
git push
echo "FIXES_PUSHED=true" >> $GITHUB_ENV
fi
- name: Comment on PR
if: env.FIXES_PUSHED == 'true' && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: "✅ Pre-commit hooks fixed formatting (black, isort) and the bot pushed the changes."
})