-
-
Notifications
You must be signed in to change notification settings - Fork 269
133 lines (128 loc) · 4.7 KB
/
issue.yml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Issue check
on:
schedule:
- cron: "0 0 */15 * *"
issues:
types: [labeled]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check title and version requirement
if: github.event_name == 'issues'
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let response = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
let data = response['data'];
data.forEach(function(issue){
var title = issue['title'];
var body = issue['body'];
var labels = issue['labels'];
var spam = false;
var invalid = false;
for(var i=0,l=labels.length;i<l;i++){
if(labels[i]['name'] == 'bug'){
if(title.substr(0, 5) !== '[Bug]' || title.trim() == '[Bug]' || title.toLowerCase().includes('hide root')){
spam = true;
}
if(body.search("### Version requirement/版本要求\n\nPublic release/beta version/公开发布/测试版\n\n") != -1 || body.search("### Version requirement/版本要求\n\nOther/其他\n\n") != -1){
invalid = true;
}
}
}
if(spam){
var id = issue['number'];
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
labels: ["spam"]
});
}
if(invalid){
var id = issue['number'];
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
labels: ["invalid"]
});
}
});
- name: Close spam and invalid
if: github.event_name == 'issues'
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let response = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
let data = response['data'];
data.forEach(function(issue){
var labels = issue['labels'];
var close = false;
var lock = false;
var rmbug = false;
for(var i=0,l=labels.length;i<l;i++){
if(labels[i]['name'] == 'invalid' || labels[i]['name'] == 'spam'){
close = true;
}
if(labels[i]['name'] == 'spam'){
lock = true;
}
if(labels[i]['name'] == 'bug'){
rmbug = true;
}
}
if(close){
var id = issue['number'];
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
body: 'This issue has been marked as **spam** or **invalid**. For feedback please **follow the rules in the report form**, then open a new issue.'
});
if(rmbug){
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
name: 'bug'
});
}
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
state: 'closed'
});
}
if(lock){
var lid = issue['number'];
github.rest.issues.lock({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
lock_reason: "spam"
});
}
});
- name: Close stale
if: github.event_name != 'issues'
uses: actions/[email protected]
with:
days-before-stale: 14
stale-issue-label: stale
stale-issue-message: It has not been updated for more than 14d. If there is no further update, this Issue will be closed.
only-labels: bug
days-before-close: 28
close-issue-message: It has not been updated for 28 days, so it was automatically closed. Open a new Issue if necessary.