개요
GitHub
에서 Pull request
를 관리할 때, 라벨(Label)
기능을 사용합니다. 또한, Release Drafter
와 같이 Pull request
의 라벨을 기준으로 동작하는 GitHub Actions
도 존재합니다.
이번 블로그 포스트에서는 GitHub Actions
의 PR Labels Checker
를 사용하여 Pull request
의 라벨이 잘 설정되었는지 검토하는 방법에 대해서 알아보도록 하겠습니다.
블로그 시리즈
이 블로그는 시리즈로 제작되었습니다. 다음 링크를 통해 다른 블로그 포스트도 확인해 보시기 바랍니다.
- [GitHub Actions] Pull request 제목 검사
- [GitHub Actions] Release Drafter를 사용하여 GitHub의 Release note 자동화 하기
- [GitHub Actions] Pull request 라벨 검사하기
- [GitHub Actions] Changelog 파일 자동 업데이트하기
PR Labels Checker
PR Labels Checker
는 Pull request
의 라벨이 적용되었는지 확인하는 GitHub Actions
입니다.
PR Labels Checker
를 사용하기 위해 .github/workflows/labels-checker.yml
파일을 만들고 다음과 같이 수정합니다.
name: Labels Checker
on:
push:
branches:
- main
pull_request:
types:
- opened
- labeled
- unlabeled
- synchronize
jobs:
check_labels:
runs-on: ubuntu-latest
steps:
- uses: danielchabr/[email protected]
with:
hasSome: breaking change,feature,bug,style,refactor,test,chore,docs,ci,dependencies
githubToken: $
이와 같이 GitHub Actions
를 생성하였다면, Pull request
에 breaking change
, feature
, bug
, style
, refactor
, test
, chore
, docs
, ci
, dependencies
중 하나의 라벨이 설정되지 않으면 에러가 발생하게 됩니다.
여기서 설정한 라벨은 Release Drafter
에서 Release note
를 자동으로 작성하기 위해 사용한 라벨입니다.
Release Drafter
저는 GitHub
의 Release note
를 자동화하기 위해 Release Drafter
를 사용하고 있습니다. Release Drafter
에 대한 자세한 내용은 다음 링크를 참고하시기 바랍니다.
저는 Release Drafter
의 autolabeler
에 의해 라벨이 잘 적용 되었는지 확인하기 위해 다음과 같은 GitHub Actions
를 사용하고 있습니다.
name: Release Drafter
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
permissions:
contents: read
jobs:
update_release_draft:
permissions:
contents: write
pull-requests: write
checks: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/[email protected]
env:
GITHUB_TOKEN: $
- uses: danielchabr/[email protected]
with:
hasSome: breaking change,feature,bug,style,refactor,test,chore,docs,ci,dependencies
githubToken: $
이렇게 GitHub Actions
를 구성하면 Pull request
가 생성될 때, Release Drafter
에 의해 자동으로 라벨이 설정되고, 이후 PR Labels Checker
가 라벨이 잘 적용되었는지 확인하게 됩니다. Release Drafter
의 autolabeler
이 라벨을 잘 작성해 주지만, 만약을 위해 한번 더 체크하도록 구성하였습니다.
완료
이것으로 GitHub Actions
의 PR Labels Checker
를 사용하여 Pull request
의 라벨이 잘 적용이 되었는지 확인하는 방법에 대해서 알아보았습니다. Pull request
의 라벨을 이용한 GitHub Actions
를 사용하거나, 라벨을 사용하여 프로젝트 관리를 하고 있다면, PR Labels Checkers
의 도입을 추천합니다.
제 블로그가 도움이 되셨나요? 하단의 댓글을 달아주시면 저에게 큰 힘이 됩니다!
앱 홍보
Deku
가 개발한 앱을 한번 사용해보세요.Deku
가 개발한 앱은 Flutter로 개발되었습니다.관심있으신 분들은 앱을 다운로드하여 사용해 주시면 정말 감사하겠습니다.