Skip to content

[Refactor] μ—”λ“œν¬μΈνŠΈ μˆ˜μ • #1

[Refactor] μ—”λ“œν¬μΈνŠΈ μˆ˜μ •

[Refactor] μ—”λ“œν¬μΈνŠΈ μˆ˜μ • #1

name: Auto Labeler
on:
issues:
types: [opened]
pull_request_target:
types: [opened, reopened]
branches: [develop]
jobs:
labeler:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Auto Labeling based on title
if: github.event_name == 'pull_request_target' || github.event_name == 'issues'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const payload = context.payload;
const isPR = !!payload.pull_request;
const target = isPR ? payload.pull_request : payload.issue;
const title = target.title;
const author = target.user.login;
const issueNumber = target.number;
const labelsToAdd = [];
const labelPatterns = {
'πŸ› Fix': /\b(fix|Fix|FIX)\b/i,
'✨ Feature': /\b(feat|Feat|FEAT)\b/i,
'πŸ“ Docs': /\b(docs|Docs|DOCS)\b/i,
'βš™οΈ Init': /\b(init|Init|INIT)\b/i,
'🎨 Design': /\b(design|Design|DESIGN)\b/i,
'πŸ”§ Chore': /\b(chore|Chore|CHORE)\b/i,
'♻️ Refactor': /\b(refactor|Refactor|REFACTOR)\b/i,
'πŸ”₯ Hotfix': /\b(hotfix|Hotfix|HOTFIX)\b/i,
'πŸš€ Deploy': /\b(deploy|Deploy|DEPLOY)\b/i
};
for (const [label, pattern] of Object.entries(labelPatterns)) {
if (pattern.test(title)) {
labelsToAdd.push(label);
}
}
const userLabels = {
"Sohyunnnn": "🐰 μ†Œν˜„",
"jisooooooooooo": "🐡 μ§€μˆ˜",
"jin-evergreen": "πŸ»β€β„οΈ 진석",
"eunkr82": "🐱 λ‚˜μ€"
};
if (userLabels[author]) {
labelsToAdd.push(userLabels[author]);
}
const uniqueLabels = [...new Set(labelsToAdd)];
if (uniqueLabels.length > 0) {
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: uniqueLabels
});
} catch (error) {
}
}