-
Notifications
You must be signed in to change notification settings - Fork 272
64 lines (55 loc) · 2.1 KB
/
closeStaleIssue.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
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
name: CloseStaleIssue
on:
schedule:
- cron: '1 15 1/8 * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Close issues of hosts label
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 is2Deal = true;
for(var i=0,l=labels.length;i<l;i++){
if(labels[i]['name'] == 'pending' || labels[i]['name'] == 'help wanted' || labels[i]['name'] == 'instruction'){
is2Deal = false;
break;
}
}
if(is2Deal){
var updated_at = new Date(issue['updated_at']);
var time_now = new Date();
var deta = time_now.getTime() - updated_at.getTime();
console.log('deta: ' + deta);
if(deta < 1000*60*60*24*30){
is2Deal = false;
}
}
if(is2Deal){
var id = issue['number'];
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
body: '由于长期没有状态更新,该问题自动关闭。如有需要可重新打开。'
});
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: id,
state: 'closed'
});
}
});