-
Notifications
You must be signed in to change notification settings - Fork 1
39 lines (35 loc) · 1.46 KB
/
issue_automation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Apply Milestone from Original Issue
on:
issues:
types: [opened, edited]
jobs:
apply-milestone:
runs-on: ubuntu-latest
steps:
- name: Check for Original Issue and Apply Milestone
uses: actions/github-script@v5
with:
script: |
const issueBody = context.payload.issue.body || ''; // issueBody가 null이면 빈 문자열로 설정
// GitHub 이슈 URL을 찾는 정규 표현식
const regex = /https:\/\/github\.com\/([^\/]+)\/([^\/]+)\/issues\/(\d+)/;
const found = issueBody.match(regex);
// 원본 이슈 링크를 찾았다면 실행
if (found) {
const originalIssueNumber = parseInt(found[3], 10);
const originalIssue = await github.rest.issues.get({
owner: found[1],
repo: found[2],
issue_number: originalIssueNumber,
});
// 원본 이슈에 마일스톤이 설정되어 있다면 새 이슈에 적용
if (originalIssue.data.milestone) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
milestone: originalIssue.data.milestone.number,
});
}
}
// 원본 이슈 링크를 찾지 못한 경우, 아무 동작도 수행하지 않음