깃헙액션을 이용하여 PR 타이틀 포맷을 자동으로 체크해줄만한게 있나 깃헙 마켓플레이스에서 찾아보다가 괜찮은 템플릿이 있길래 사용해보았다.
우선 ./github/workflows 폴더에 lint_pr.yml이라는 파일을 생성하였다.
그리고 description에 쓰여있는대로 뼈대를 작성하였고 내 입맛에 맞게 configuration을 추가하였다.
name: 'Lint PR'
on:
pull_request:
types:
- opened
- edited
branches:
- stage
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
with:
types: |
fix
feat
docs
style
refactor
typo
chore
ci
subjectPattern: ^[ㄱ-ㅎ가-힣a-zA-Z0-9 ]{5,50}$
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
pull_request:
types:
- opened
- edited
branches:
- stage
stage branch로 pull request가 발생할 때 workflow를 실행한다.
types
더 자세한 설정은 여기
steps:
- uses: amannn/action-semantic-pull-request@v5
with:
types: |
fix
feat
docs
style
refactor
typo
chore
ci
subjectPattern: ^[ㄱ-ㅎ가-힣a-zA-Z0-9 ]{5,50}$
yml파일을 작성하고 stage브랜치에 PR을 날려보았다.
제목부분이 5글자 이하라 실패해야하는것이 나의 의도이다.
결과는
실패
다음은 성공해야하는 제목으로 수정하였다.
성공 ✨