Created
July 18, 2023 16:11
-
-
Save nickadam/092f5291c7508486b9093fe1b86e645d to your computer and use it in GitHub Desktop.
List Org Repos and Contributors
This file contains hidden or 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
$org = "Your Org" | |
$api_key = "Your PAT" | |
function Get-GitHubApi(){ | |
param($Url) | |
$Headers = @{Authorization = "Bearer $api_key"} | |
$wr = Invoke-WebRequest -UseBasicParsing -Headers $Headers $Url | |
$wr.Content | ConvertFrom-Json -Depth 100 | |
if([string]($wr.Headers.link -split "," -match 'rel="next"') -match "https[^>]+"){ | |
Get-GitHubApi $matches[0] | |
} | |
} | |
$repos = Get-GitHubApi "https://api.github.com/orgs/$org/repos" | |
$repos | ForEach-Object { | |
$full_name = $_.full_name | |
$html_url = $_.html_url | |
$contributors = Get-GitHubApi "https://api.github.com/repos/$full_name/contributors" | |
$contributors_list = $contributors.login -join ', ' | |
[PSCustomObject]@{ | |
Url = $html_url | |
Contributors = $contributors_list | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment