File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 5555 const daysSinceUpdate = Math.floor((now - updatedAt) / (1000 * 60 * 60 * 24));
5656 console.log(` Days since update: ${daysSinceUpdate}`);
5757
58- // If PR was updated and has stale label, remove it
59- if (labels.includes(staleLabel) && daysSinceUpdate < daysUntilStale) {
58+ // Check if the last activity was setting the stale label
59+ const events = await github.rest.issues.listEvents({
60+ owner: context.repo.owner,
61+ repo: context.repo.repo,
62+ issue_number: pr.number,
63+ per_page: 10
64+ });
65+
66+ const lastEvent = events.data.length > 0 ? events.data[events.data.length - 1] : null;
67+ const isStaleLastActivity = lastEvent &&
68+ lastEvent.event === 'labeled' &&
69+ lastEvent.label &&
70+ lastEvent.label.name === staleLabel;
71+
72+ // If PR was updated and has stale label, remove it (unless the last activity was setting the stale label)
73+ if (labels.includes(staleLabel) && daysSinceUpdate < daysUntilStale && !isStaleLastActivity) {
6074 console.log(` Removing stale label (PR was updated)`);
6175 try {
6276 await github.rest.issues.removeLabel({
You can’t perform that action at this time.
0 commit comments