Skip to content

Instantly share code, notes, and snippets.

@thoughtful-solutions
Last active October 17, 2024 08:26
Show Gist options
  • Save thoughtful-solutions/a2997542150af1c88587f43df2739bb7 to your computer and use it in GitHub Desktop.
Save thoughtful-solutions/a2997542150af1c88587f43df2739bb7 to your computer and use it in GitHub Desktop.
Github_CLI

Some musing on github (gh) cli

Configure on dnf Linux access.

Install packages

sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh --repo gh-cli

Configure Authentications

gh auth login
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org', 'workflow'.
? Paste your authentication token: ****************************************
- gh config set -h github.com git_protocol https
✓ Configured git protocol
! Authentication credentials saved in plain text
✓ Logged in as thoughtful-solutions

List the repos

  gh repo list

  gh repo list SelectIDLtd   
  
  gh api repos/SelectIDLtd/AuditServer/collaborators

List teams and members

  gh api orgs/SelectIDLtd/teams
  
  gh api orgs/SelectIDLtd/teams/selectid-read/members

List user and search information

  gh api users/thoughtful-solutions
  
  gh api search/users --method=GET -f q="[email protected] in:email"

List an organisation and members

notice that for some queries you cannot use the names of the team or organisation you have to use the numeric team value.

  gh api orgs/SelectIDLtd/teams

  gh api organizations/173607686/team/10596797/members
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment