-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (42 loc) · 1.76 KB
/
commit-labeler.yaml
File metadata and controls
46 lines (42 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: "Commit Message Labeler"
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
commit-labeler:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.PERSONAL_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
const commits = await github.rest.pulls.listCommits({ owner, repo, pull_number: number });
const labels = new Set();
for (const c of commits.data) {
const msg = c.commit.message.toLowerCase();
if (msg.includes("feat")) labels.add("🚀 feat");
if (msg.includes("fix")) labels.add("🚨 fix");
if (msg.includes("docs")) labels.add("📄 docs");
if (msg.includes("style")) labels.add("🌱 style");
if (msg.includes("refactor")) labels.add("🔄 refactor");
if (msg.includes("test")) labels.add("✅ test");
if (msg.includes("perf")) labels.add("⚡️ perf");
if (msg.includes("chore")) labels.add("⚒️ chore");
if (msg.includes("ci")) labels.add("🔧 ci");
if (msg.includes("hotfix")) labels.add("🛟 hotfix");
if (msg.includes("release")) labels.add("💫 release");
if (msg.includes("rename")) labels.add("🎫 rename");
if (msg.includes("remove")) labels.add("✂️ remove");
}
if (labels.size > 0) {
await github.rest.issues.addLabels({
owner,
repo,
issue_number: number,
labels: Array.from(labels),
});
}