Skip to content

Apply Milestone from Original Issue #22

Apply Milestone from Original Issue

Apply Milestone from Original Issue #22

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,
});
}
}
// 원본 이슈 링크를 찾지 못한 경우, 아무 동작도 수행하지 않음