forked from anuragverma108/SwapReads
-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (37 loc) · 1.4 KB
/
issuereminder.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
name: Issue Reminder
on:
schedule:
# Runs every day at 8 AM
- cron: '0 8 * * *'
jobs:
remind-stale-issues:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Find and remind stale issues
uses: actions/github-script@v6
with:
script: |
const daysBeforeReminder = 7;
const staleDate = new Date(Date.now() - daysBeforeReminder * 24 * 60 * 60 * 1000);
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
since: staleDate.toISOString(),
});
const staleIssues = issues.filter(issue => new Date(issue.updated_at) < staleDate);
for (const issue of staleIssues) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `👋 This issue hasn't been updated in over ${daysBeforeReminder} days. Please check in to see if it is still relevant!`,
});
}
if (staleIssues.length === 0) {
console.log('No stale issues found. All issues are up-to-date.');
} else {
console.log(`${staleIssues.length} stale issue(s) found and reminded.`);
}