-
Notifications
You must be signed in to change notification settings - Fork 7
42 lines (39 loc) · 1.37 KB
/
stale-issues.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: Label Stale Issues
on:
schedule:
- cron: '0 0 * * *'
jobs:
add_stale_label:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Set "stale" label on update
uses: actions/github-script@v6
with:
script: |
const needsStale = (issue) => {
const labels = issue.labels.map(labelObj => labelObj.name);
return (issue.assignees !== undefined
&& issue.assignees.length > 0
&& !labels.includes('epic')
&& !labels.includes('stale')
&& issue.state === 'open'
&& new Date(issue.updated_at) <= new Date() - 14 * 24 * 60 * 60 * 1000);
}
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
for (const issue of issues) {
if (!issue.pull_request && await needsStale(issue)) {
console.log(`Adding STALE to issue #${issue.number}: ${issue.title}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['stale']
});
}
}