Open1

GitHubCli導入

ふじしろふじしろ

https://cli.github.com/

Brewからインストール

$ brew install gh

インストール成功を確認

$ gh --version
gh version 2.32.0 (2023-07-11)
https://github.com/cli/cli/releases/tag/v2.32.0

PRのリストを取得しようとしてみたらログインしろと言われた

$ gh pr list
To get started with GitHub CLI, please run:  gh auth login
Alternatively, populate the GH_TOKEN environment variable with a GitHub API authentication token.

指示通りgh auth loginを実行

$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? /Users/<user>/.ssh/<pem>.pem.pub
? Title for your SSH key: GitHub CLI
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: XXXX-XXXX
Press Enter to open github.com in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ SSH key already existed on your GitHub account: /Users/<user>/.ssh/<pem>.pem.pub
✓ Logged in as <GitHub username>