Skip to content

Commit

Permalink
1 week left should only activate if last activity was 3 weeks ago, no…
Browse files Browse the repository at this point in the history
…t one week ago.
  • Loading branch information
pattonw committed Jan 22, 2024
1 parent 2501064 commit b1823bd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/close-inactive-prs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ jobs:
const prs = await github.rest.pulls.list({ owner, repo, state: 'open' });
const thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 28);
const oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
const threeWeeksAgo = new Date();
threeWeeksAgo.setDate(threeWeeksAgo.getDate() - 21);
for (const pr of prs.data) {
const updatedAt = new Date(pr.updated_at);
const number = pr.number;
if (updatedAt < thirtyDaysAgo) {
await github.rest.pulls.update({ owner, repo, pull_number: number, state: 'closed' });
console.log(`Closed PR #${number}`);
} else if (updatedAt < oneWeekAgo) {
} else if (updatedAt < threeWeeksAgo) {
const message = 'This PR will be closed in one week due to inactivity. Please update the PR if necessary.';
await github.rest.issues.createComment({ owner, repo, issue_number: number, body: message });
console.log(`Posted warning on PR #${number}`);
Expand Down

0 comments on commit b1823bd

Please sign in to comment.