-
Notifications
You must be signed in to change notification settings - Fork 65
44 lines (37 loc) · 1.47 KB
/
stale_check.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
name: Comment on stale assigned issues
on:
schedule:
- cron: '0 0 */6 * *' # Runs every 6 days at midnight
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
comment-on-stale-issues:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Comment on stale assigned issues
uses: actions/github-script@v6
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
assignee: '*'
});
const now = new Date();
const fiveDaysInMilliseconds = 5 * 24 * 60 * 60 * 1000;
for (const issue of issues.data) {
if (issue.assignees.length > 0) {
const assignedAt = new Date(issue.created_at); // Assuming issue assigned date is the same as issue created date
const timeDiff = now - assignedAt;
if (timeDiff > fiveDaysInMilliseconds) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `This issue has been assigned to @${issue.assignees[0].login} for more than 5 days. Please provide an update.`
});
}
}
}