Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub list team members #192

Closed

Conversation

bavarianbidi
Copy link
Contributor

This PR is based on the branch used in #191 (so let's get #191 done first).
Use commit c6e8a63 to see the new feature.

Instead of adding multiple github users it would be also nice to only define at least one team in github and add all users to the list of users to lookup for a public key.

TODO:

if a GitHub Enterprise instance requires authentication for every
endpoint it's not possible to fetch the public keys via
<URL>/<username>.keys

With a dedicated PAT with the scope read:public_key it's possible to
fetch the public keys via the API

Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
instead of defining every team member via the --github-user flag it
would be also nice if all members could be defined via the new --github-team flag
@owenthereal
Copy link
Owner

This use case is interesting. I would say perhaps the best way is to combo upterm with the gh CLI for such a use case:

upterm host $(gh api /orgs/ORG_NAME/teams/TEAM_NAME/members | jq -r 'map("--github-user \"\(.login)\"") | join(" ")')

The above gets all team members for a team and supply their logins as --github-user LOGIN into the upterm host command with jq. We have to strike a balance of how deep integration upterm should go with external APIs.

@owenthereal owenthereal closed this Oct 9, 2023
@bavarianbidi
Copy link
Contributor Author

bavarianbidi commented Oct 10, 2023

@owenthereal thanks for your recent changes towards our needs.

Unfortanetly for the github-team-member-lookup the token need more permissions. In my case i can't do a login with the limited token i've used in this branch. It seems that gh is doing some additional requests instead of the api-requests from google/go-github.

runner@road-runner-os023-l-h28fgkqwkhfb:~/actions-runner/_work/pipeline-test/pipeline-test$ echo $GITHUB_TOKEN | gh auth login -h $GH_HOST --with-token
error validating token: missing required scope 'repo'

will try to work around that to make it work - maybe by duing a curl request for that.
Will let you know about the result.

UPDATE

yes indeed,

doing a plain curl (documented in the official gh documentation) works fine where the gh api subcommand requires a successful gh auth login first to work ... and gh auth login requires a token with repo scope 😞 ).

will continue with curl for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants