@@ -11,13 +11,25 @@ jobs:
11
11
runs-on : ubuntu-latest
12
12
13
13
steps :
14
- - name : Assign Labels to Issue
15
- if : github.event.issue != null
14
+ - name : Assign Labels
16
15
uses : actions/github-script@v6
17
16
with :
18
17
script : |
19
- const title = context.payload.issue.title.toLowerCase();
20
- const body = context.payload.issue.body ? context.payload.issue.body.toLowerCase() : '';
18
+ let issue_number;
19
+ let title = '';
20
+ let body = '';
21
+ if (context.payload.issue) {
22
+ issue_number = context.payload.issue.number;
23
+ title = context.payload.issue.title.toLowerCase();
24
+ body = context.payload.issue.body ? context.payload.issue.body.toLowerCase() : '';
25
+ } else if (context.payload.pull_request) {
26
+ issue_number = context.payload.pull_request.number;
27
+ title = context.payload.pull_request.title.toLowerCase();
28
+ body = context.payload.pull_request.body ? context.payload.pull_request.body.toLowerCase() : '';
29
+ } else {
30
+ throw new Error('No issue or pull request found in context.');
31
+ }
32
+
21
33
const labels = [];
22
34
if (title.includes('bug') || body.includes('bug') || title.includes('error') || body.includes('error') || title.includes('problem') || body.includes('problem')) {
23
35
labels.push('bug');
@@ -30,38 +42,27 @@ jobs:
30
42
} else {
31
43
labels.push('needs-triage');
32
44
}
33
- github.issues.addLabels({
45
+
46
+ await github.issues.addLabels({
34
47
owner: context.repo.owner,
35
48
repo: context.repo.repo,
36
- issue_number: context.payload.issue.number ,
37
- labels: labels
49
+ issue_number,
50
+ labels,
38
51
});
39
52
40
- - name : Assign Issue to Maintainer
53
+ - name : Assign to PaulAndersonS (Issues only)
41
54
if : github.event.issue != null
42
55
uses : actions/github-script@v6
43
56
with :
44
57
script : |
45
- const title = context.payload.issue.title.toLowerCase();
46
- const assignees = [];
47
- // Replace these usernames with your repo's contributors or teams
48
- if (title.includes('bug')) {
49
- assignees.push('bug-fixer');
50
- } else if (title.includes('feature')) {
51
- assignees.push('feature-dev');
52
- } else if (title.includes('docs') || title.includes('documentation')) {
53
- assignees.push('docs-maintainer');
54
- }
55
- if (assignees.length > 0) {
56
- github.issues.addAssignees({
57
- owner: context.repo.owner,
58
- repo: context.repo.repo,
59
- issue_number: context.payload.issue.number,
60
- assignees: assignees
61
- });
62
- }
58
+ await github.issues.addAssignees({
59
+ owner: context.repo.owner,
60
+ repo: context.repo.repo,
61
+ issue_number: context.payload.issue.number,
62
+ assignees: ['PaulAndersonS']
63
+ });
63
64
64
- - name : Add Thank You Comment on Issue
65
+ - name : Add Comment (Issues)
65
66
if : github.event.issue != null
66
67
uses : actions/github-script@v6
67
68
with :
@@ -78,38 +79,14 @@ jobs:
78
79
type = 'question';
79
80
}
80
81
const comment = `Thank you for your ${type}! We will review it soon.`;
81
- github.issues.createComment({
82
+ await github.issues.createComment({
82
83
owner: context.repo.owner,
83
84
repo: context.repo.repo,
84
85
issue_number: context.payload.issue.number,
85
86
body: comment
86
87
});
87
88
88
- - name : Assign Labels to PR
89
- if : github.event.pull_request != null
90
- uses : actions/github-script@v6
91
- with :
92
- script : |
93
- const title = context.payload.pull_request.title.toLowerCase();
94
- const body = context.payload.pull_request.body ? context.payload.pull_request.body.toLowerCase() : '';
95
- const labels = [];
96
- if (title.includes('bugfix') || body.includes('bugfix') || title.includes('fix') || body.includes('fix')) {
97
- labels.push('bug');
98
- } else if (title.includes('feature') || body.includes('feature') || title.includes('enhancement') || body.includes('enhancement')) {
99
- labels.push('enhancement');
100
- } else if (title.includes('docs') || body.includes('docs') || title.includes('documentation') || body.includes('documentation')) {
101
- labels.push('documentation');
102
- } else {
103
- labels.push('needs-triage');
104
- }
105
- github.issues.addLabels({
106
- owner: context.repo.owner,
107
- repo: context.repo.repo,
108
- issue_number: context.payload.pull_request.number,
109
- labels: labels
110
- });
111
-
112
- - name : Add Thank You Comment on PR
89
+ - name : Add Comment (Pull Requests)
113
90
if : github.event.pull_request != null
114
91
uses : actions/github-script@v6
115
92
with :
@@ -124,7 +101,7 @@ jobs:
124
101
type = 'documentation PR';
125
102
}
126
103
const comment = `Thank you for your ${type}! We will review it soon.`;
127
- github.issues.createComment({
104
+ await github.issues.createComment({
128
105
owner: context.repo.owner,
129
106
repo: context.repo.repo,
130
107
issue_number: context.payload.pull_request.number,
0 commit comments