Skip to content

Commit b7a21c9

Browse files
authored
Merge pull request #11 from YAPP-Github/BOOK-51-chore/#10
chore: PR 라벨링 워크플로우 github-script로 전환
2 parents a8502b2 + 4735671 commit b7a21c9

File tree

2 files changed

+34
-38
lines changed

2 files changed

+34
-38
lines changed

.github/labeler.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/PR_Label_Assign.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,41 @@ on:
55
types: [opened, edited, reopened]
66

77
jobs:
8-
label:
8+
label-pr:
99
runs-on: ubuntu-latest
1010

11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
1115
steps:
12-
- name: Label PR by title
13-
uses: jimschubert/labeler-action@v2
16+
- name: Label PR based on title
17+
uses: actions/github-script@v6
1418
with:
15-
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
19+
script: |
20+
const prTitle = context.payload.pull_request.title;
21+
22+
const labelMap = [
23+
{ pattern: /^feat:/i, label: '✨ feat' },
24+
{ pattern: /^fix:/i, label: '🐞 fix' },
25+
{ pattern: /^chore:/i, label: '⚙️ chore' },
26+
{ pattern: /^docs:/i, label: '📃 docs' },
27+
{ pattern: /^refactor:/i, label: '🔨 refactor' },
28+
{ pattern: /^test:/i, label: '✅ test' }
29+
];
30+
31+
const labelsToAdd = labelMap
32+
.filter(entry => entry.pattern.test(prTitle))
33+
.map(entry => entry.label);
34+
35+
if (labelsToAdd.length > 0) {
36+
await github.rest.issues.addLabels({
37+
issue_number: context.issue.number,
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
labels: labelsToAdd
41+
});
42+
core.info(`Added labels: ${labelsToAdd.join(', ')}`);
43+
} else {
44+
core.info('No matching labels found for PR title.');
45+
}

0 commit comments

Comments
 (0)