-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fixes issues activity automations (#3457)
- Loading branch information
Showing
2 changed files
with
12 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
$inactivityDelay = [timespan]::FromDays([int]::Parse($Env:NO_RECENT_ACTIVITY_DURATION_CLOSE_IN_DAYS)) | ||
$oldIssues = gh issue list --label "$Env:NO_RECENT_ACTIVITY_LABEL" --state open --limit 100 --json number,author,createdAt | ConvertFrom-Json | ||
$oldIssues = gh issue list --label "$Env:NO_RECENT_ACTIVITY_LABEL" --state open --limit 100 --json number,author,createdAt,labels | ConvertFrom-Json | Where-Object {$_.labels.name -notcontains $Env:NEEDS_ATTENTION_LABEL } | ||
foreach($oldIssue in $oldIssues) { | ||
$lastComment = gh issue view $oldIssue.number --json comments | ConvertFrom-Json | Select-Object -ExpandProperty comments | Where-Object {$_.author.login -eq $oldIssue.author.login} | Select-Object -Last 1 | ||
if($null -eq $lastComment) { | ||
$lastCommentDate = [datetime]::Parse($oldIssue.createdAt) | ||
|
||
$lastCommentDate = [datetime]$null | ||
} else { | ||
$lastCommentDate = [datetime]::Parse($lastComment.createdAt) | ||
$lastCommentDate = $lastComment.createdAt #powershell already parses the date for us with the json conversion | ||
} | ||
$lastLabelEvent = gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/$($Env:ORG_NAME)/$($Env:REPO_NAME)/issues/$($oldIssue.number)/events?per_page=100" | ConvertFrom-Json | Where-Object {$_.event -eq "labeled" -and $_.label.name -eq "$Env:NO_RECENT_ACTIVITY_LABEL"} | Select-Object -Last 1 | ||
$lastLabelEventDate = [datetime]::Parse($lastLabelEvent.created_at) | ||
if ($lastCommentDate -gt $lastLabelEventDate) { | ||
$lastLabelEventDate = $lastLabelEvent.created_at | ||
if ($null -ne $lastCommentDate -and $lastCommentDate -gt $lastLabelEventDate) { | ||
gh issue edit $oldIssue.number --remove-label "$Env:NO_RECENT_ACTIVITY_LABEL" --remove-label "$Env:NEEDS_AUTHOR_FEEDBACK_LABEL" --add-label "$Env:NEEDS_ATTENTION_LABEL" | ||
} elseif (($lastLabelEventDate - $lastCommentDate) -ge $inactivityDelay) { | ||
} elseif (([datetime]::UtcNow - $lastLabelEventDate) -ge $inactivityDelay) { | ||
gh issue close $oldIssue.number -r "not planned" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters