Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 17 additions & 36 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,44 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: (PR) Format Python Code

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
branches: [ "main" ] # PR이 main 브랜치에 머지될 때 실행

permissions:
contents: write
pull-requests: write # PR에 직접 커밋할 수 있도록 권한 추가

jobs:
python-code-format:
runs-on: ubuntu-20.04
# 실행할 단계 정의
steps:
# GitHub 리포지토리를 체크아웃 (클론)
- name: Checkout code
uses: actions/checkout@v2

# Python 환경 설정
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # PR의 소스 브랜치를 체크아웃

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10" # Python 3.10 버전 사용
architecture: "x64"

# Python 버전 확인
python-version: "3.10"
architecture: "x64"

- name: Display Python version
run: python --version # Python 버전 표시
run: python --version

# 필요한 Python 패키지 설치
- name: Install packages
run: pip install black isort autopep8

# 코드 포맷팅 작업 수행
- name: Formatter
run: |
black .
autopep8 --recursive --in-place --aggressive --aggressive . # autopep8를 사용하여 코드 포맷팅
isort . # isort를 사용하여 코드 포맷팅

# 변경사항 Commit # 아잇 왜 안대
autopep8 --recursive --in-place --aggressive --aggressive .
isort .

- name: Commit format changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "Github Action"
git remote set-url origin https://x-access-token:${{ secrets.SECRET_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Automated format fixes"
git push

# # PR 생성
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v3
# with:
# commit-message: Auto code format # 커밋 메시지
# title: Fixes by format action # 풀 리퀘스트 제목
# body: This is an auto-generated PR with fixes. # 풀 리퀘스트 본문
# labels: automated pr # 레이블
# branch: python-code-format-patches # 새로운 브랜치 이름
git config --local user.name "GitHub Action"
git diff --quiet || (git commit -am "Automated format fixes" && git push origin ${{ github.head_ref }})
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub Actions 제공 토큰 사용
Loading