name: PR Title Validation
on:
pull_request:
types: [opened, edited, reopened]
jobs:
title-check:
runs-on: ubuntu-latest
steps:
- name: Check PR Title
run: |
title=$(jq -r '.pull_request.title' $GITHUB_EVENT_PATH)
if [[ "$title" =~ ^(\[Feat\]|\[Refactor\]|\[Fix\]|\[Test\]|\[Chore\]|\[Setting\]|\[Docs\]) ]]; then
echo "PR Title is valid."
else
echo "PR Title is invalid."
exit 1
fi
위의 yaml 파일을 .github/workflows 하위에 위치시키면 워크플로우로 등록된다.
정규식을 사용해 PR title이 [Feat], [Refactor], [Fix], [Test], [Chore], [Setting], [Docs] 로 시작하는 경우만 validation을 통과하도록 작성했다.
'기타 > Github Actions' 카테고리의 다른 글
GitHub Actions을 이용한 Docker 이미지 빌드 및 AWS EC2 배포 자동화 (1) | 2023.05.26 |
---|