@@ -11,65 +11,131 @@ jobs:
11
11
runs-on : ubuntu-latest
12
12
13
13
steps :
14
- - name : Assign Labels
15
- if : github.event.issue
14
+ - name : Assign Labels to Issue
15
+ if : github.event.issue != null
16
16
uses : actions/github-script@v6
17
17
with :
18
18
script : |
19
- const issue = context.issue;
19
+ const title = context.payload.issue.title.toLowerCase();
20
+ const body = context.payload.issue.body ? context.payload.issue.body.toLowerCase() : '';
20
21
const labels = [];
21
- if (issue. title.includes('bug')) {
22
+ if (title.includes('bug') || body.includes('bug') || title.includes('error') || body.includes('error') || title.includes('problem') || body.includes('problem ')) {
22
23
labels.push('bug');
23
- } else if (issue. title.includes('feature')) {
24
+ } else if (title.includes('feature') || body.includes('feature') || title.includes('request') || body.includes('request') || title.includes('suggestion') || body.includes('suggestion') || title.includes('improvement') || body.includes('improvement ')) {
24
25
labels.push('enhancement');
26
+ } else if (title.includes('docs') || body.includes('docs') || title.includes('documentation') || body.includes('documentation')) {
27
+ labels.push('documentation');
28
+ } else if (title.includes('question') || body.includes('question')) {
29
+ labels.push('question');
25
30
} else {
26
31
labels.push('needs-triage');
27
32
}
28
33
github.issues.addLabels({
29
34
owner: context.repo.owner,
30
35
repo: context.repo.repo,
31
- issue_number: issue.number,
36
+ issue_number: context.payload. issue.number,
32
37
labels: labels
33
38
});
34
39
35
- - name : Assign Issues
36
- if : github.event.issue
40
+ - name : Assign Issue to Maintainer
41
+ if : github.event.issue != null
37
42
uses : actions/github-script@v6
38
43
with :
39
44
script : |
40
- const issue = context.issue;
45
+ const title = context.payload. issue.title.toLowerCase() ;
41
46
const assignees = [];
42
- if (issue.title.includes('bug')) {
47
+ // Replace these usernames with your repo's contributors or teams
48
+ if (title.includes('bug')) {
43
49
assignees.push('bug-fixer');
44
- } else if (issue. title.includes('feature')) {
50
+ } else if (title.includes('feature')) {
45
51
assignees.push('feature-dev');
52
+ } else if (title.includes('docs') || title.includes('documentation')) {
53
+ assignees.push('docs-maintainer');
46
54
}
47
- github.issues.addAssignees({
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
+ }
63
+
64
+ - name : Add Thank You Comment on Issue
65
+ if : github.event.issue != null
66
+ uses : actions/github-script@v6
67
+ with :
68
+ script : |
69
+ const title = context.payload.issue.title.toLowerCase();
70
+ let type = 'issue';
71
+ if (title.includes('bug')) {
72
+ type = 'bug report';
73
+ } else if (title.includes('feature')) {
74
+ type = 'feature request';
75
+ } else if (title.includes('docs') || title.includes('documentation')) {
76
+ type = 'documentation update';
77
+ } else if (title.includes('question')) {
78
+ type = 'question';
79
+ }
80
+ const comment = `Thank you for your ${type}! We will review it soon.`;
81
+ github.issues.createComment({
82
+ owner: context.repo.owner,
83
+ repo: context.repo.repo,
84
+ issue_number: context.payload.issue.number,
85
+ body: comment
86
+ });
87
+
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({
48
106
owner: context.repo.owner,
49
107
repo: context.repo.repo,
50
- issue_number: issue .number,
51
- assignees: assignees
108
+ issue_number: context.payload.pull_request .number,
109
+ labels: labels
52
110
});
53
111
54
- - name : Add Comment
55
- if : github.event.issue
112
+ - name : Add Thank You Comment on PR
113
+ if : github.event.pull_request != null
56
114
uses : actions/github-script@v6
57
115
with :
58
116
script : |
59
- const issue = context.issue;
60
- const comment = `Thank you for your ${issue.title.includes('bug') ? 'bug report' : 'feature request'}! We will review it soon.`;
117
+ const title = context.payload.pull_request.title.toLowerCase();
118
+ let type = 'pull request';
119
+ if (title.includes('bugfix') || title.includes('fix')) {
120
+ type = 'bug fix PR';
121
+ } else if (title.includes('feature')) {
122
+ type = 'feature PR';
123
+ } else if (title.includes('docs') || title.includes('documentation')) {
124
+ type = 'documentation PR';
125
+ }
126
+ const comment = `Thank you for your ${type}! We will review it soon.`;
61
127
github.issues.createComment({
62
128
owner: context.repo.owner,
63
129
repo: context.repo.repo,
64
- issue_number: issue .number,
130
+ issue_number: context.payload.pull_request .number,
65
131
body: comment
66
132
});
67
133
68
- - name : Close Stale Issues
134
+ - name : Close Stale Issues and PRs
69
135
uses : actions/stale@v4
70
136
with :
71
137
repo-token : ${{ secrets.GITHUB_TOKEN }}
72
138
stale-issue-message : ' This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.'
73
139
stale-pr-message : ' This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.'
74
- days-before-stale : 30
75
- days-before-close : 7
140
+ days-before-stale : 60
141
+ days-before-close : 14
0 commit comments