Last active
January 31, 2022 03:52
-
-
Save zmughal/76ed32e7c5c02b25fdbe9bb3190d6ca7 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
MY_USER=$(gh repo list --json owner -q '.[0].owner.login') | |
BOTS="dependabot renovate snyk-bot" | |
BOTS_CONDITION=$(echo $BOTS | tr ' ' '\n' | sed 's/^/ and .author.login != "/; s/$/" /' ) | |
SELECT_AUTHORS=".author.login != \"$MY_USER\" $BOTS_CONDITION" | |
gh api graphql --paginate -f query=' | |
query($endCursor: String) { | |
viewer { | |
repositories(ownerAffiliations: [OWNER,COLLABORATOR,ORGANIZATION_MEMBER], first: 100, after: $endCursor) { | |
nodes { | |
viewerPermission, | |
nameWithOwner, | |
pullRequests(first: 100, states: OPEN) { | |
totalCount | |
nodes { | |
author { login } | |
} | |
} | |
} | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
} | |
} | |
} | |
' --jq ' | |
.[].viewer.repositories.nodes | |
| map( select( | |
.pullRequests.totalCount > 0 | |
and | |
.viewerPermission != "READ" | |
) ) | |
| .[]' \ | |
| jq -c ' | |
.pullRequests.authors = [ | |
.pullRequests.nodes | map(select( '"$SELECT_AUTHORS"' )) | |
| .[] | .author.login ] | |
| { | |
name: (.nameWithOwner), | |
count: (.pullRequests.authors | length), | |
authors: (.pullRequests.authors) | |
}' \ | |
| jq -sc ' map(select(.count>0)) | .[]' \ | |
| sort | jq -c . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment