๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ”ฅ ํ”„๋กœ์ ํŠธ/์›จ๋”ฉ๋ฉ”์ดํŠธ

[Github Actions] PR open ์‹œ ๋ผ๋ฒจ ์ถ”๊ฐ€ํ•˜๊ณ  closed ์‹œ ์‚ญ์ œํ•˜๊ธฐ

by nitronium102 2023. 8. 15.

ํ˜„์žฌ ์ƒํ™ฉ

PR ๋ฆฌ๋ทฐ ๊ด€๋ จ ๋ผ๋ฒจ์„ ๋งŒ๋“ค์–ด์„œ ๋ฆฌ๋ทฐ ์ƒํ™ฉ ๋ฐ ๋ฐ˜์˜ ์ƒํ™ฉ์„ ํŠธ๋ž˜ํ‚นํ•˜๊ณ  ์žˆ์—ˆ๋‹ค

 

ํ๋ฆ„์€ ๋Œ€๋žต ์•„๋ž˜์™€ ๊ฐ™๋‹ค

1. PR open : ๋ฆฌ๋ทฐ ํ•„์š” ๋ผ๋ฒจ ์ถ”๊ฐ€

- ๋ฆฌ๋ทฐ์ค‘ : ๋ฆฌ๋ทฐ์–ด๊ฐ€ ๋ฆฌ๋ทฐ ์ค‘์ธ ๊ฒฝ์šฐ

- ๋‹ต๋ณ€ ํ•„์š” : ๋ฆฌ๋ทฐ ๊ณผ์ • ์ค‘์— ์งˆ๋ฌธ์ด ์ƒ๊ฒจ PR ๋‹ด๋‹น์ž์˜ ๋‹ต๋ณ€์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ

- ์ˆ˜์ • ์š”์ฒญ : request changes์ธ ๊ฒฝ์šฐ

- ์ˆ˜์ • ๋ฐ˜์˜ ์ค‘ : ์š”์ฒญ๋œ ์ˆ˜์ • ์‚ฌํ•ญ์„ ๋ฐ˜์˜ํ•˜๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ

- ๋จธ์ง€ ๊ฐ€๋Šฅ : ๋ฆฌ๋ทฐ์–ด๊ฐ€ ๋ฆฌ๋ทฐ ์™„๋ฃŒํ•˜๊ณ  ๋ฌธ์ œ ์—†๋Š” ๊ฒฝ์šฐ

2. PR close : ๋จธ์ง€ ๊ฐ€๋Šฅ ๋ผ๋ฒจ ์‚ญ์ œ

 

 

 

ํ•˜์ง€๋งŒ ๋งค๋ฒˆ PR์„ ์˜ฌ๋ฆด ๋•Œ๋งˆ๋‹ค ๋ผ๋ฒจ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ๋„ ๊ท€์ฐฎ์•˜๋‹ค

๊ทธ๋ฆฌ๊ณ  ๊ฐ€์žฅ ์‹ซ์—ˆ๋˜ ๊ฒƒ์€ PR์„ ๋จธ์ง€ํ•œ ์ดํ›„์— ๋‚จ๋Š” ์ง„ํ–‰๊ณผ์ • ๋ผ๋ฒจ๋“ค์ด์—ˆ๋‹ค!! 

 

 

์ด์ „ ํ”„๋กœ์ ํŠธ์—์„œ ๋‚จ์€ ์ˆ˜๋งŽ์€ ๋ผ๋ฒจ๋“ค...

 

์ง€๊ธˆ๊นŒ์ง€๋Š” ์ˆ˜๋™์œผ๋กœ ๋จธ์ง€ ์‹œ ํ•ด๋‹น ๋ผ๋ฒจ์„ ์ œ๊ฑฐํ•˜๊ณ  ์žˆ์—ˆ์ง€๋งŒ PR ๊ฐœ์ˆ˜๊ฐ€ ๋Š˜์–ด๋‚จ์— ๋”ฐ๋ผ ๋„ˆ๋ฌด๋‚˜๋„ ๊ท€์ฐฎ์•„์กŒ๋‹ค.

๊ทธ๋ž˜์„œ github action ์Šคํฌ๋ฆฝํŠธ ์ž‘์„ฑ์— ๋„์ „ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค!

 

Github Action marketPlace๋ฅผ ์ด์šฉํ•˜์ž

์ฒ˜์Œ์—๋Š” ๋‚ด๊ฐ€ ์ง์ ‘ ์ž‘์„ฑํ•ด๋ณด๋ ค๊ณ  ํ–ˆ์œผ๋‚˜ Curl -X ๋ฅผ ์ด์šฉํ•ด์„œ ์‚ญ์ œ ๋ฐ ์ถ”๊ฐ€ ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ๋ถ€๋ถ„์—์„œ ์ž๊พธ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค

๊ทธ๋ž˜์„œ ๊ทธ๋ƒฅ ์ž˜ ๋งŒ๋“ค์–ด๋†“์€ ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์˜ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ๋‹ค

 

์—ฌ๋Ÿฌ ์œ ๋ช…ํ•œ Actions ๋“ค์ด ๋งŽ์•˜์ง€๋งŒ ๋‹ค๋“ค PR์—์„œ ๋ฌด์–ธ๊ฐ€๋ฅผ ์ฝ์–ด์„œ ๊ทธ๊ฑฐ์— ๋งž๊ฒŒ ๋ผ๋ฒจ์„ ๋‹ฌ์•„์ฃผ๋Š” action์ด์—ˆ๋‹ค!

๋‚ด๊ฐ€ ํ•„์š”ํ•œ ๊ฑด ๋‹จ์ˆœํžˆ ๋ผ๋ฒจ์„ ๋‹ฌ์•„์ฃผ๋Š” actions์ด์—ˆ๊ธฐ ๋•Œ๋ฌธ์— star๊ฐ€ ์ ๋”๋ผ๋„ ๊ทธ๋ƒฅ ์‚ฌ์šฉํ–ˆ๋‹ค

 

Github Token ๋“ฑ๋ก

๋ญ ์–ด๋””์—์„œ๋Š” ์ž๋™์œผ๋กœ ๋“ฑ๋ก๋œ๋‹ค๊ณ  ํ•˜๋Š”๋ฐ ๋‚˜๋Š” ์ „ํ˜€ ๋จนํžˆ์ง€ ์•Š์•˜๋‹ค!

๊ทธ๋ž˜์„œ ๊ฑ ๋ฐœ๊ธ‰๋ฐ›๊ณ  ๊ฐœ์ธ ํ† ํฐ์œผ๋กœ ๋“ฑ๋กํ–ˆ๋‹ค.

 

[Github Token ๋ฐœ๊ธ‰]

1. Profile - Settings - Developer Settings ์ง„์ž…

2. Personal Access tokens - Tokens (classic) - Generate new token(classic) (์ƒˆ๋กœ ๋ญ ๋‚˜์™”๋˜๋ฐ beta๋ผ ์•ˆ ์ผ๋‹ค)

3. ์—ฌ๊ธฐ์—์„œ ๋ฐœ๊ธ‰ ๋ฐ›์€ ํ† ํฐ ๊ฐ’์„ ์ž˜ ์ €์žฅํ•ด์ค€๋‹ค

 

[Github Token ๋“ฑ๋ก]

1. Action์„ ๋“ฑ๋กํ•  repository๋กœ ์ด๋™

2. Settings - Secrets and variables - Actions

3. New Repository secret ํด๋ฆญ

4. ์›ํ•˜๋Š” ํ† ํฐ ์ด๋ฆ„ ์ž…๋ ฅ ํ›„ ๋ฐœ๊ธ‰๋ฐ›์€ Github Token ์ž…๋ ฅ

์ฐธ๊ณ ๋กœ GITHUB_์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” ํ† ํฐ์€ ์ž…๋ ฅํ•  ์ˆ˜ ์—†์œผ๋‹ˆ ์•Œ์•„์„œ ๋‹ค๋ฅธ ๊ฐ’์„ ์ƒ๊ฐํ•ด๋ณด๋„๋ก ํ•˜์ž

 

ํŒ€ ํ”„๋กœ์ ํŠธ์— ๋‚ด ๊ฐœ์ธ ํ† ํฐ ๋“ฑ๋กํ•ด๋†“๋Š” ๊ฑฐ๋ผ ์ด๋ฆ„์„ ์ €๋ ‡๊ฒŒ ์ง€์–ด๋†จ๋‹ค

 

 

PR open ์‹œ ํŠน์ • ๋ผ๋ฒจ ์ถ”๊ฐ€

PR์ด ์—ด๋ฆด ๋•Œ๋งˆ๋‹ค ๐Ÿ‘€๋ฆฌ๋ทฐํ•„์š” ๋ผ๋ฒจ ์ถ”๊ฐ€

 

https://github.com/actions-ecosystem/action-add-labels

 

GitHub - actions-ecosystem/action-add-labels: ๐Ÿท๏ธ GitHub Action to add labels

๐Ÿท๏ธ GitHub Action to add labels. Contribute to actions-ecosystem/action-add-labels development by creating an account on GitHub.

github.com

 

์•„์ง ์˜ค๋ฅ˜๊ฐ€ ์žˆ์–ด์„œ ์ด์Šˆ๋ฅผ ๋ณด๊ณ  ๊ถŒํ•œ ์ถ”๊ฐ€ํ•˜๋Š” ๋ช…๋ น์–ด๋ฅผ ์ถ”๊ฐ€ํ–ˆ๋‹ค

 

name: Add Label to PRs

on:
  pull_request:
    types:
      - opened

jobs:
  add_label:
    runs-on: ubuntu-latest

	# repository์— ๊ถŒํ•œ ๋ถ€์—ฌ
    permissions:
      contents: read
      pull-requests: write

    steps:
      - name: checkout
        uses: actions/checkout@v2

      - name: add label
        uses: actions-ecosystem/action-add-labels@v1.1.0
        with:
          github_token: ${{ secrets.PERSONAL_TOKEN }}
          labels: ๐Ÿ‘€๋ฆฌ๋ทฐํ•„์š”

 

PR close ์‹œ ํŠน์ • ๋ผ๋ฒจ ์ œ๊ฑฐ

PR ๋‹ซํž ๋•Œ ๐Ÿ˜Š๋จธ์ง€๊ฐ€๋Šฅโ“๋‹ต๋ณ€ํ•„์š”๐Ÿ‘€๋ฆฌ๋ทฐํ•„์š”๐Ÿ’ช์ˆ˜์ •์š”์ฒญ๐Ÿ’ป์ˆ˜์ •๋ฐ˜์˜์ค‘๐Ÿ–Œ๋ฆฌ๋ทฐ์ค‘ ๋ผ๋ฒจ ์ œ๊ฑฐ 

 

https://github.com/actions-ecosystem/action-remove-labels

 

GitHub - actions-ecosystem/action-remove-labels: ๐Ÿท๏ธ GitHub Action to remove labels

๐Ÿท๏ธ GitHub Action to remove labels. Contribute to actions-ecosystem/action-remove-labels development by creating an account on GitHub.

github.com

 

PR์— ๋ผ๋ฒจ์ด ์—†๋Š” ๊ฒฝ์šฐ์—๋Š” ์—๋Ÿฌ๊ฐ€ ๋‚˜์„œ action์ด ๋ฉˆ์ถ˜๋‹ค๋Š” ์ด์Šˆ๊ฐ€ ์•„์ง๋„ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์•˜๋‹ค.

๊ทธ๋ž˜์„œ ๊ทธ๋ƒฅ ์—๋Ÿฌ๊ฐ€ ๋‚œ ๊ฒฝ์šฐ์—๋„ ๋ฌด์‹œํ•˜๊ณ  ๋Œ์•„๊ฐ€๋„๋ก ํ•˜๋Š” fail_on_error๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ false๋กœ ์ฃผ์—ˆ๋‹ค(์ด action ํ•œ์ •)

 

๊ถŒํ•œ ์ถ”๊ฐ€ํ•˜๋Š” ๋ช…๋ น์–ด๋„ ์ฃผ์—ˆ๋‹ค

name: Remove Labels

on:
  pull_request:
    types:
      - closed

jobs:
  remove_labels:
    runs-on: ubuntu-latest

	# repository ๊ด€๋ จ ๊ถŒํ•œ ์ถ”๊ฐ€
    permissions:
      contents: read
      pull-requests: write

    steps:
      - uses: actions/checkout@v2
      - uses: actions-ecosystem/action-remove-labels@v1.3.0
        with:
          github_token: ${{ secrets.PERSONAL_TOKEN }}
          # ์—๋Ÿฌ ๋ฌด์‹œ
          fail_on_error: false
          labels: |
            ๐Ÿ˜Š๋จธ์ง€๊ฐ€๋Šฅ
            โ“๋‹ต๋ณ€ํ•„์š”
            ๐Ÿ‘€๋ฆฌ๋ทฐํ•„์š”
            ๐Ÿ’ช์ˆ˜์ •์š”์ฒญ
            ๐Ÿ’ป์ˆ˜์ •๋ฐ˜์˜์ค‘
            ๐Ÿ–Œ๋ฆฌ๋ทฐ์ค‘

 

๊ฒฐ๊ณผ

์•„์ฃผ ์ž˜ ๋Œ์•„๊ฐ€๊ณ  ์•„์ฃผ ํŽธ๋ฆฌํ•˜๋‹ค!

๊ทผ๋ฐ ๋‚ด Github Token์œผ๋กœ ๋“ฑ๋กํ•ด์„œ ๊ทธ๋Ÿฐ๊ฐ€ ๋‹ค๋ฅธ ๋ถ„๋“ค PR์—๋„ ๋‚ด๊ฐ€ ๋ผ๋ฒจ์„ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋– ์„œ ์กฐ๊ธˆ ๋ฏผ๋งํ•˜๋‹คใ…Ž..

์ˆ˜์ƒํ•˜๋ฆฌ๋งŒํผ PR์ด ์˜ฌ๋ผ์˜ค๋ฉด ๋‹ฌ๋ ค์˜ค๋Š” ์—ฌ์„ฑ

 

 

๋Œ“๊ธ€