Skip to content

Gh cli

Usage

PR list and review

gh pr list
Showing 1 of 1 open pull request in KantarProfiles/teams
ID    TITLE              BRANCH            CREATED AT
#594  Cleanup terraform  chore/tf-cleanup  about 12 hours ago

gh pr view 594

PR approval

cd $REPO

gh pr list
Showing 1 of 1 open pull request in KantarProfiles/teams
ID    TITLE              BRANCH            CREATED AT
#594  Cleanup terraform  chore/tf-cleanup  about 10 hours ago

gh pr review -a 594
✓ Approved pull request KantarProfiles/teams#594

Install gh command line

cd /opt/pkg/

dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
dnf install -y gh

gh --version

gh auth status
gh auth refresh -h github.com

gh auth status
The last CLI should show status like these:
github.com
  ✓ Logged in to github.com account ox0 (/root/.config/gh/hosts.yml)
  - Active account: true
  - Git operations protocol: ssh
  - Token: gho_************************************
  - Token scopes: 'gist', 'read:org', 'repo'

Authenticate to orgnization

Make sure login exist.

gh auth status
gh api user/orgs --jq '.[].login'
Follow this:
# gh auth refresh -h github.com -s user,repo

! First copy your one-time code: 6282-60A6
Press Enter to open https://github.com/login/device in your browser...
/usr/bin/xdg-open: line 881: www-browser: command not found
/usr/bin/xdg-open: line 881: links2: command not found
/usr/bin/xdg-open: line 881: elinks: command not found
/usr/bin/xdg-open: line 881: links: command not found
/usr/bin/xdg-open: line 881: lynx: command not found
/usr/bin/xdg-open: line 881: w3m: command not found
xdg-open: no method available for opening 'https://github.com/login/device'
! Failed opening a web browser at https://github.com/login/device
  exit status 3
  Please try entering the URL in your browser manually
Make sure you modified https://github.com/login/device
to:
https://github.com.mcas.ms/login/device
Otherwise, organization of KantarProfiles never get approved.

Verify run

gh repo list

gh repo list LightspeedGMI
gh repo list KantarProfiles