-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: dn-rule 워크플로우 스크립트 작성 * chore: dn-rule 워크플로우 스크립트 수정 * chore: dn-rule 워크플로우 스크립트 수정 * chore: dn-rule 워크플로우 스크립트 수정 * chore: dn-rule 워크플로우 pull_request 적용 타입 수정
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: PR Label Automation | ||
on: | ||
pull_request: | ||
types: [ opened ] | ||
schedule: | ||
- cron: '0 0 * * *' # 매일 자정에 실행 | ||
|
||
jobs: | ||
update-labels: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check and Update PR Labels | ||
uses: actions/github-script@v5 | ||
with: | ||
script: | | ||
const repo = context.repo; | ||
const prNumber = context.payload.pull_request ? context.payload.pull_request.number : context.issue.number; | ||
// PR 레이블 가져오기 | ||
const { data: pr } = await github.rest.pulls.get({ | ||
owner: repo.owner, | ||
repo: repo.repo, | ||
pull_number: prNumber, | ||
}); | ||
let labels = pr.labels.map(label => label.name); | ||
const hasDLabel = labels.some(label => label.startsWith("D-")); | ||
// 'D-' 레이블이 없는 경우 'D-5' 레이블 추가 | ||
if (!hasDLabel) { | ||
await github.rest.issues.addLabels({ | ||
owner: repo.owner, | ||
repo: repo.repo, | ||
issue_number: prNumber, | ||
labels: ['D-5'], | ||
}); | ||
console.log("Added D-5 label to PR"); | ||
} | ||
// 'D-x' 레이블 확인 및 업데이트 | ||
for (let label of labels) { | ||
if (label.startsWith("D-") && label !== "D-0") { | ||
let day = parseInt(label.split("-")[1]); | ||
if (day > 0) { | ||
let newLabel = `D-${day - 1}`; | ||
// 먼저 기존 레이블을 제거 | ||
await github.rest.issues.removeLabel({ | ||
owner: repo.owner, | ||
repo: repo.repo, | ||
issue_number: prNumber, | ||
name: label, | ||
}); | ||
// 새 레이블 추가 | ||
await github.rest.issues.addLabels({ | ||
owner: repo.owner, | ||
repo: repo.repo, | ||
issue_number: prNumber, | ||
labels: [newLabel], | ||
}); | ||
console.log(`Updated label from ${label} to ${newLabel}`); | ||
} | ||
if (day === 1) { | ||
// 'D-0' 처리 로직 | ||
} | ||
break; | ||
} | ||
} |