Data: 전체적인 모델링 코드 추가(참고용) #17
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
name: Create and Close Issue From Commit | |
on: | |
push: | |
branches: | |
- main # 원하는 다른 브랜치로 변경 가능 | |
jobs: | |
create_and_close_issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create and Close Issue | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
// 1. 첫 번째 커밋 정보 추출 | |
const commit = context.payload.commits[0]; | |
// 2. 커밋 메시지를 줄 단위로 분리 | |
const commitMessageLines = commit.message.split('\n'); | |
// 3. 첫 줄을 issue의 Title로 사용 | |
const title = commitMessageLines[0]; | |
// 4. 나머지 줄은 issue의 Description으로 사용 | |
const description = commitMessageLines.slice(1).join('\n').trim(); | |
// 5. issue 본문 생성 | |
const issueBody = `Commit details:\n- Author: ${commit.author.name}\n- Link: ${commit.url}\n\n${description}`; | |
// 6. GitHub API를 사용하여 issue 생성 | |
const issue = { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: title, | |
body: issueBody | |
} | |
// 7. 생성된 issue 번호를 얻어와서 해당 issue를 닫음 | |
github.issues.create(issue).then((issueResponse) => { | |
github.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueResponse.data.number, | |
state: 'closed' | |
}); | |
}); |