Open5

GitHub CLIに入門してみるゾウ

Kumamoto-HamachiKumamoto-Hamachi

セットアップ

インストール

Linuxでのghインストール | 公式

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

バージョン確認

[kumamoto ~]$ which gh
/usr/bin/gh
[kumamoto ~]$ gh --version
gh version 2.5.1 (2022-02-15)
https://github.com/cli/cli/releases/tag/v2.5.1

認証

[kumamoto ~]$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? 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... 
既存のブラウザ セッションで開いています。

Webブラウザで認証

[19715:19715:0100/000000.560516:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as Kumamoto-Hamachi

確認

[kumamoto ~]$ gh auth status
github.com
  ✓ Logged in to github.com as Kumamoto-Hamachi (/home/kumamoto/.config/gh/hosts.yml)
  ✓ Git operations for github.com configured to use https protocol.
  ✓ Token: *******************
Kumamoto-HamachiKumamoto-Hamachi

基本的な使い方

issue の取得

$ gh issue list

PR 一覧の取得

$ gh pr list

自分のプルリクの検索

-- myprでエイリアスとして登録
$ gh alias set mypr "pr list -s all -a Kumamoto(ユーザー名)"

-- 検索の実行
$ gh mypr | grep "ほげほげ"

最新リリースの取得 TODO

$ gh release view

ワークフローの実行 TODO