λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
πŸ§‘πŸ»‍πŸ’» Develop/GitHub

Pull Requests 에 μžλ™μœΌλ‘œ Labels μ μš©ν•˜κΈ° (1) - Auto Labeler

by dev-jaesoon 2022. 9. 26.

GitHub Labels μ΄λž€?

GitHub Label 은 Pull Requests (μ΄ν•˜ PR) λ˜λŠ” Issues μ—μ„œ μΉ΄ν…Œκ³ λ¦¬λ₯Ό λΆ„λ₯˜ν•˜κΈ° μœ„ν•΄ μ‚¬μš©λœλ‹€. GitHub μ—μ„œλ„ 이미 기본적으둜 9개의 Labels λ₯Ό μ œκ³΅ν•˜κ³  μžˆλ‹€.

 

GitHub Labels

νŒ€ ν”„λ‘œμ νŠΈλ₯Ό ν•˜κ³  μžˆλ‹€λ©΄ μ—¬λŸ¬ λͺ…μ˜ νŒ€μ›μ΄ 각자의 μž‘μ—… λ‚΄μš©μ„ μ—¬λŸ¬ 개의 PR 을 λ§Œλ“€μ–΄ 병합할텐데, 이 λ•Œ Labels 을 μ‚¬μš©ν•œλ‹€λ©΄ 보닀 효율적으둜 μž‘μ—… λ‚΄μš©(PR)듀을 관리할 수 μžˆλ‹€.

 

Auto Labeler 적용

GitHub actions 에 Auto Labeler plugins 을 μ μš©ν•˜μ—¬ μ‚¬μš©ν•  것이닀. κ·Έ μ€‘μ—μ„œλ„ Auto Labeler λ₯Ό μ‚¬μš©ν•˜μ—¬ PR 의 Title μ΄λ‚˜ Description 에 νŠΉμ • λ‚΄μš©μ΄ μΆ”κ°€ λ˜μ—ˆμ„ λ•Œ GitHub actions κ°€ μž‘λ™ν•˜λ„λ‘ ν•  것이닀. λ¨Όμ € 일반적인 github actions κ³Ό λ˜‘κ°™μ΄ YAML νŒŒμΌμ„ 생성해쀀닀. (기본적인 μ‚¬μš©λ²•μ€ Document 에 λͺ¨λ‘ μž‘μ„±λ˜μ–΄ μžˆλ‹€.)

μžλ™μœΌλ‘œ labeling ν•˜κΈ° μœ„ν•œ GitHub Actions Plugin

 

  • .github/workflows/labeler.yml : Auto Labeler κ°€ 싀행될 쑰건에 λŒ€ν•œ workflows λ₯Ό μž‘μ„±
  • .github/labeler.yml : μžλ™μœΌλ‘œ labeling 이 될 기쀀에 λŒ€ν•˜μ—¬ μž‘μ„±

 

μ‹€ν–‰ 쑰건 μ •μ˜

.github/workflows/labeler.yml

릴리즈λ₯Ό μœ„ν•΄ main λΈŒλžœμΉ˜μ— λŒ€ν•œ PRκ°€ opened λ˜λŠ” reopened λ˜μ—ˆμ„ λ•Œ, μžλ™μœΌλ‘œ λΌλ²¨λ§λ˜λ„λ‘ ν•˜κΈ° μœ„ν•΄ μ•„λž˜μ™€ 같이 μž‘μ„±ν•œλ‹€.

name: Auto Labeler
on:
  pull_request:
    types: [opened, reopened]
    branches:
      - main

그리고  jobs λ₯Ό μ•„λž˜μ™€ 같이 μž‘μ„±ν•˜μ—¬ Auto Labeler λ₯Ό μ„€μ •ν•΄μ€€λ‹€. μ΄λ•Œ ν™˜κ²½ λ³€μˆ˜μΈ GITHUB_TOKEN 은 μžλ™μœΌλ‘œ μƒμ„±λ˜κΈ° λ•Œλ¬Έμ— 별도 섀정은 λΆˆν•„μš”ν•˜λ‹€.

jobs:
  labeler:
    runs-on: ubuntu-latest
    steps:
      - name: Check Labels
        id: labeler
        uses: jimschubert/labeler-action@v2
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/labeler.yml

크게 live release PR 와 Refactoring PR 2가지에 λŒ€ν•΄μ„œ Auto Labeler κ°€ μ μš©λ˜λ„λ‘ ν•˜λ €κ³  ν•œλ‹€. μ•„λž˜μ™€ 같이 μž‘μ„±ν•˜λ©΄ λ˜λŠ”λ°, comment λŠ” labeling μ‹œ μžλ™μœΌλ‘œ μž‘μ„±λ  문ꡬ, labels λŠ” νŠΉμ • 문ꡬ가 Title μ΄λ‚˜ Description 에 μžˆμ„ 경우 μžλ™μœΌλ‘œ 적용될 Label  을 μ •μ˜ν•œ κ²ƒμœΌλ‘œ Key κ°€ 적용될 labels, Values κ°€ 식별할 문ꡬ가 λœλ‹€. 

comment: |
  🏷 I have applied any labels matching special text in your title and description.

labels:
  "🌏 live":
    - '\blive release\b'
  "πŸ›  refactoring":
    - '\bRefactoring\b'

μ—¬λŸ¬κ°€μ§€λ₯Ό ν…ŒμŠ€νŠΈ μ§„ν–‰ν•΄λ³΄μ•˜λŠ”λ°, λŒ€/μ†Œλ¬Έμž ꡬ뢄을 ν•˜λŠ” μ •κ·œν‘œν˜„μ‹(/i)이 적용이 μ•ˆ λ˜μ—ˆκΈ° λ•Œλ¬Έμ—, ν•„μš”ν•˜λ‹€λ©΄ 경우의 수 λ³„λ‘œ λ”°λ‘œ 적어쀄 ν•„μš”κ°€ μžˆμ„ λ“― ν•˜λ‹€. λ˜ν•œ, ν•΄λ‹Ή 파일이 κΈ°μ€€ 브랜치 (main λ˜λŠ” master) 에 μ μš©λ˜μ§€ μ•ŠμœΌλ©΄, μ œλŒ€λ‘œ μž‘λ™ν•˜μ§€ μ•ŠλŠ” λ¬Έμ œκ°€ μžˆμ—ˆλ‹€.

 

μ‹€ν–‰ κ²°κ³Ό 확인

PR을 μƒμ„±ν•˜κ³  μΌμ •μ‹œκ°„μ„ 기닀리면 μ•„λž˜μ™€ 같이 μžλ™μœΌλ‘œ github-actions(bot) 에 μ˜ν•΄ labeling 이 λ˜λŠ” 것을 확인할 수 μžˆλ‹€. 그리고 각 label 을 ν΄λ¦­ν•˜μ—¬ ν•΄λ‹Ή label 이 뢙은 PR 만 λͺ¨μ•„ 검색 κ²°κ³Όλ₯Ό 확인할 μˆ˜λ„ μžˆλ‹€.

μžλ™μœΌλ‘œ labeling 이 λ˜μ–΄, μ—¬λŸ¬κ°œμ˜ PR이 λ³΅μž‘ν•˜κ²Œ μžˆμ–΄λ„ μ‰½κ²Œ ꡬ뢄할 수 μžˆλ‹€

 

μ΄λ²ˆμ— μ‚¬μš©ν•΄λ³Έ Auto labeler λŠ” μ•„μ‰¬μš΄ 뢀뢄듀이 μžˆμ—ˆκΈ° λ•Œλ¬Έμ—, κ·Έ λ‹€μŒμ—λŠ” μ΄μ–΄μ„œλŠ” PR의 λ³€κ²½ λ‚΄μš©μ„ ν™•μΈν•˜κ³ , 그에 따라 μžλ™μœΌλ‘œ labeling ν•΄μ£ΌλŠ” Plugin 을 μ‚¬μš©ν•΄λ³΄κ² λ‹€.

λŒ“κΈ€