[TASK-92, TASK-93, TASK-94] style: 작품 업로드 페이지 UI 구현 #154
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: Auto Label PR | |
on: | |
pull_request: | |
types: [opened, edited, synchronize] | |
jobs: | |
auto-label: | |
runs-on: ubuntu-latest | |
steps: | |
# PR 이벤트 트리거 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 커밋 메시지 키워드에 따라 라벨 추가 | |
- name: Add labels based on commit messages | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const commitKeywords = { | |
feat: 'feature', | |
fix: 'bug', | |
chore: 'chore', | |
docs: 'documentation', | |
style: 'style', | |
refactor: 'refactor', | |
test: 'test', | |
perf: 'performance', | |
}; | |
// context와 github는 기본적으로 제공됨 | |
const { owner, repo } = context.repo; | |
const pullRequestNumber = context.payload.pull_request.number; | |
const { data: commits } = await github.rest.pulls.listCommits({ | |
owner, | |
repo, | |
pull_number: pullRequestNumber, | |
}); | |
const labelsToAdd = new Set(); | |
commits.forEach(commit => { | |
const keyword = commit.commit.message.split(':')[0].trim(); | |
if (commitKeywords[keyword]) { | |
labelsToAdd.add(commitKeywords[keyword]); | |
} | |
}); | |
if (labelsToAdd.size > 0) { | |
await github.rest.issues.addLabels({ | |
owner, | |
repo, | |
issue_number: pullRequestNumber, | |
labels: [...labelsToAdd], | |
}); | |
console.log('Labels added:', [...labelsToAdd]); | |
} else { | |
console.log('No matching labels found for commits.'); | |
} |