1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

powershellでgithubリポジトリのissue一覧を取得し、CSVで出力する方法

Last updated at Posted at 2020-07-01

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


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?