Skip to content

Instantly share code, notes, and snippets.

@yknx4
Created January 24, 2022 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yknx4/1bc073e83501df97b6c15964079be5d3 to your computer and use it in GitHub Desktop.
Save yknx4/1bc073e83501df97b6c15964079be5d3 to your computer and use it in GitHub Desktop.
Get Team SSH Keys from Github Organization
gh api graphql -F login='ORG' -F team='TEAM' -f query='
query ($login: String!, $team: String!) {
organization(login: $login) {
team(slug: $team) {
members(first: 100) {
edges {
node {
name
login
publicKeys(first: 100) {
edges {
node {
key
}
}
}
}
}
}
}
}
}
' --jq 'getpath(["data","organization", "team", "members", "edges"]) | map(.node | .publicKeys = (.publicKeys.edges | map(.node.key))) | map(select(.publicKeys | length >= 1)) | map({key:.publicKeys[], login}) | map(.key + " " + .login) | join("\n")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment