privateリポジトリの場合はあらかじめgithubでアクセストークンを取得しておく
$since = '2020-01-01'
$TOKEN = 'トークン'
$ORG = 'オーガナイザ'
$REP = 'リポジトリ'
# per_pageは100がmax
# issueの数にもよるがとりあえず100x10の1000件まで取得
for($i = 1; $i -lt 10; $i++) {
$url = "https://api.github.com/repos/$ORG/$REP/issues?per_page=100&page=$i&state=all&since=$since"
$issues = (Invoke-RestMethod $url -Headers @{Authorization="token $TOKEN"}) `
| select -Property number, title, state, @{Name='closed_at'; Expression={[System.DateTime]::Parse($_.closed_at).ToString('yyyy-MM-dd')}}, html_url, assignees `
| where { ($_.closed_at -ge $from -and $_.closed_at -ne $to)} `
| where { $_.html_url.Contains('issue')}
foreach($issue in $issues){
$assignees = ($issue.assignees | select -expand login) -join ' '
$issue.assignees = $assignees
}
$issues | Export-Csv "tmp_github_issue$i.csv" -Encoding Default -NoTypeInformation
}
type tmp_github_issue*.csv > github_issue.csv
Remove-Item tmp_github_issue*.csv