Skip to content

Commit 64c02f8

Browse files
authored
Merge branch 'OAI:main' into main
2 parents 1598721 + 6627c32 commit 64c02f8

File tree

4 files changed

+89
-3
lines changed

4 files changed

+89
-3
lines changed

.github/workflows/agenda.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,31 @@ on:
1313
schedule:
1414
- cron: '0 16 * * 4'
1515
workflow_dispatch: {}
16-
16+
17+
permissions:
18+
issues: write
19+
contents: read
20+
1721
jobs:
1822
agenda:
1923
env:
2024
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
TITLE_PREFIX: "Open Community (TDC) Meeting, "
26+
LABEL: "Housekeeping"
27+
POST_MEETING_CLOSE_DURATION_IN_DAYS: 10
2128

2229
runs-on: ubuntu-latest
2330

2431
steps:
25-
- uses: actions/checkout@v1 # checkout repo content
32+
- uses: actions/checkout@v4 # checkout repo content
2633

2734
- name: Create agenda issue
28-
run: gh issue create -l Housekeeping -t "Open Community (TDC) Meeting, `date --date='next Thu' +'%A %d %B %Y'`" -F .github/templates/agenda.md
35+
run: |
36+
$nextThursday = @(@(1..8) | % {$(Get-Date).AddDays($_)} | ? {$_.DayOfWeek -ieq "Thursday"})[0].ToString("dddd dd MMMM yyyy", [CultureInfo]::InvariantCulture)
37+
$result = gh issue create -l ${{ env.LABEL }} -t "${{ env.TITLE_PREFIX }}$nextThursday" -F .github/templates/agenda.md
38+
gh issue pin $result
39+
shell: pwsh
2940

41+
- name: Close old agenda issues
42+
run: gh issue list -l ${{ env.LABEL }} --author "app/github-actions" --json number,title | ConvertFrom-Json | Where-Object { $_.title -like "${{ env.TITLE_PREFIX }}*" -and ([datetime]::UtcNow - [datetime]::Parse([regex]::Replace($_.title.Replace("${{ env.TITLE_PREFIX }}", ""), "\([^)]+\)", ""))) -ge [timespan]::FromDays([int]::Parse("${{ env.POST_MEETING_CLOSE_DURATION_IN_DAYS }}"))} | ForEach-Object { gh issue close $_.number && gh issue unpin $_.number }
43+
shell: pwsh

.github/workflows/inactive-issues.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
issues:
3+
types: labeled
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '*/5 * * * *'
7+
8+
permissions:
9+
issues: write
10+
contents: read
11+
12+
name: Label and close issues with no recent activity
13+
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
NEEDS_ATTENTION_LABEL: "Needs attention"
17+
NEEDS_AUTHOR_FEEDBACK_LABEL: "Needs author feedback"
18+
NO_RECENT_ACTIVITY_LABEL: "No recent activity"
19+
NO_RECENT_ACTIVITY_DURATION_IN_DAYS: 7
20+
NO_RECENT_ACTIVITY_DURATION_CLOSE_IN_DAYS: 28
21+
ORG_NAME: ${{ github.repository_owner }}
22+
REPO_NAME: ${{ github.event.repository.name }}
23+
NO_RECENT_ACTIVITY_COMMENT: "This issue has been labeled with `No recent activity` because there has been no recent activity. It will be closed if no further activity occurs within 28 days. Please re-open this issue or open a new one after this delay if you need to."
24+
25+
26+
jobs:
27+
run:
28+
runs-on: ubuntu-latest
29+
name: Label issues with no recent activity
30+
steps:
31+
- uses: actions/checkout@v4
32+
- run: scripts/label-no-recent.ps1
33+
shell: pwsh
34+
- run: scripts/close-no-recent.ps1
35+
shell: pwsh

scripts/close-no-recent.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$inactivityDelay = [timespan]::FromDays([int]::Parse($Env:NO_RECENT_ACTIVITY_DURATION_CLOSE_IN_DAYS))
2+
$oldIssues = gh issue list --label "$Env:NO_RECENT_ACTIVITY_LABEL" --state open --limit 100 --json number,author,createdAt | ConvertFrom-Json
3+
foreach($oldIssue in $oldIssues) {
4+
$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
5+
if($null -eq $lastComment) {
6+
$lastCommentDate = [datetime]::Parse($oldIssue.createdAt)
7+
8+
} else {
9+
$lastCommentDate = [datetime]::Parse($lastComment.createdAt)
10+
}
11+
$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
12+
$lastLabelEventDate = [datetime]::Parse($lastLabelEvent.created_at)
13+
if ($lastCommentDate -gt $lastLabelEventDate) {
14+
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"
15+
} elseif (($lastLabelEventDate - $lastCommentDate) -ge $inactivityDelay) {
16+
gh issue close $oldIssue.number -r "not planned"
17+
}
18+
}

scripts/label-no-recent.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
$inactivityDelay = [timespan]::FromDays([int]::Parse($Env:NO_RECENT_ACTIVITY_DURATION_IN_DAYS))
2+
$oldIssues = gh issue list --label "$Env:NEEDS_AUTHOR_FEEDBACK_LABEL" --state open --limit 100 --json number,author,createdAt | ConvertFrom-Json
3+
foreach($oldIssue in $oldIssues) {
4+
$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
5+
if($null -eq $lastComment) {
6+
$lastCommentDate = [datetime]::Parse($oldIssue.createdAt)
7+
8+
} else {
9+
$lastCommentDate = [datetime]::Parse($lastComment.createdAt)
10+
}
11+
$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:NEEDS_AUTHOR_FEEDBACK_LABEL"} | Select-Object -Last 1
12+
$lastLabelEventDate = [datetime]::Parse($lastLabelEvent.created_at)
13+
if ($lastCommentDate -gt $lastLabelEventDate) {
14+
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"
15+
} elseif (($lastLabelEventDate -$lastCommentDate) -ge $inactivityDelay) {
16+
gh issue edit $oldIssue.number --add-label "$Env:NO_RECENT_ACTIVITY_LABEL" --remove-label "$Env:NEEDS_ATTENTION_LABEL"
17+
gh issue comment $oldIssue.number -b "$Env:NO_RECENT_ACTIVITY_COMMENT"
18+
}
19+
}

0 commit comments

Comments
 (0)