1
- name : Set Pay attention label for ignored issues
1
+ name : Set label for issues and pull request
2
2
on :
3
- schedule :
4
- - cron : ' 0 11 */2 * *'
5
- - cron : ' 0 11 */7 * *'
3
+ workflow_dispatch :
4
+
6
5
jobs :
7
6
set-label-for-issues :
8
7
runs-on : ubuntu-latest
9
8
steps :
10
- - name : Set label for issues
11
- if : github.event.schedule == '0 11 */2 * *'
9
+ - name : Set label for pull requests and issues
12
10
uses : actions/github-script@v7
13
11
with :
14
12
github-token : ${{ secrets.GITHUB_TOKEN }}
@@ -19,34 +17,16 @@ jobs:
19
17
})
20
18
if (issuesList.data && issuesList.status === 200) {
21
19
for (const issue of issuesList.data) {
22
- if (!issue.pull_request && !issue.labels.length) {
20
+ const createdDaysDelta = (new Date() - new Date(issue.created_at)) / (1000 * 60 * 60 * 24);
21
+
22
+ if (!issue.labels.length && (
23
+ (!issue.pull_request && createdDaysDelta > 2) || (issue.pull_request && createdDaysDelta > 7)
24
+ )) {
23
25
await github.rest.issues.addLabels({
24
26
owner: context.repo.owner,
25
27
repo: context.repo.repo,
26
28
issue_number: issue.number,
27
- labels: ['pay attention']
28
- });
29
- }
30
- }
31
- }
32
- - name : Set label for pull requests
33
- if : github.event.schedule == '0 11 */7 * *'
34
- uses : actions/github-script@v7
35
- with :
36
- github-token : ${{ secrets.GITHUB_TOKEN }}
37
- script : |
38
- const issuesList = await github.rest.issues.listForRepo({
39
- owner: context.repo.owner,
40
- repo: context.repo.repo,
41
- })
42
- if (issuesList.data && issuesList.status === 200) {
43
- for (const issue of issuesList.data) {
44
- if (issue.pull_request && !issue.labels.length) {
45
- await github.rest.issues.addLabels({
46
- owner: context.repo.owner,
47
- repo: context.repo.repo,
48
- issue_number: issue.number,
49
- labels: ['pay attention']
29
+ labels: ['bug']
50
30
});
51
31
}
52
32
}
0 commit comments