-
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (95 loc) · 3.65 KB
/
auto-assign.yml
File metadata and controls
108 lines (95 loc) · 3.65 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Auto Assign PR
on:
pull_request:
types: [opened, ready_for_review]
permissions:
pull-requests: write
jobs:
assign-author:
name: Assign PR Author
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Assign PR to author
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request.number;
const author = context.payload.pull_request.user.login;
// Assign PR to author
await github.rest.issues.addAssignees({
owner,
repo,
issue_number: prNumber,
assignees: [author]
});
console.log(`Assigned PR #${prNumber} to @${author}`);
request-review:
name: Request Review from Code Owner
runs-on: ubuntu-latest
if: |
github.event.pull_request.draft == false &&
github.event.pull_request.user.login != 'mithun50'
steps:
- name: Request review from owner
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request.number;
try {
await github.rest.pulls.requestReviewers({
owner,
repo,
pull_number: prNumber,
reviewers: ['mithun50']
});
console.log(`Requested review from @mithun50 for PR #${prNumber}`);
} catch (error) {
console.log(`Could not request review: ${error.message}`);
}
add-priority-label:
name: Add Priority Label
runs-on: ubuntu-latest
steps:
- name: Check and label priority
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request.number;
const title = context.payload.pull_request.title.toLowerCase();
const body = context.payload.pull_request.body?.toLowerCase() || '';
let labels = [];
// Priority detection
if (title.includes('hotfix') || title.includes('critical') || title.includes('urgent')) {
labels.push('priority/critical');
} else if (title.includes('bug') || title.includes('fix')) {
labels.push('priority/high');
} else if (title.includes('feat')) {
labels.push('priority/medium');
}
// Type detection from conventional commits
if (title.startsWith('feat')) labels.push('type/feature');
if (title.startsWith('fix')) labels.push('type/bugfix');
if (title.startsWith('docs')) labels.push('type/documentation');
if (title.startsWith('refactor')) labels.push('type/refactor');
if (title.startsWith('perf')) labels.push('type/performance');
if (title.startsWith('test')) labels.push('type/test');
// Breaking change detection
if (title.includes('!') || body.includes('breaking change')) {
labels.push('breaking-change');
}
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner,
repo,
issue_number: prNumber,
labels: labels
});
console.log(`Added labels: ${labels.join(', ')}`);
}