exploring the github cli

Published on

Today I was setting up my new work notebook, and was about to go the usual flow of creating/configuring SSH keys linked to your GitHub account, through github.com

Decided to explore the GitHub CLI and make good use of some fancy GitHub CLI commands to improve my Git(Hub) workflow.

Installation

Started with a simple brew install gh.

Exploring gh

Without even checking the docs, the most intuitive thing to do was to simply write gh in the terminal.

There seems to be an additional auth command.

Alright, with gh auth login you can authenticate the CLI with your GitHub account through your browser. Neat!

The manual

At cli.github.com/manual you can find the CLI docs and check out the various commands in detail on the web.

Cloning repos

As simple as

gh repo clone username/repo

Neat!

GitHub Actions and Workflows

I used this command to check the latest GitHub Actions run for this repo:

gh run list

The run command is used to list, view, and watch recent workflow runs from GitHub Actions.

Another cool thing was then to view the last failed run:

gh run view 1396070003 --log

If it’s confusing in the terminal, you can view the pipeline in the browser with

gh run view 1396070003 --web

You can also list your workflows

gh workflow list

And trigger a build with

gh workflow run 43771

Conclusion

Yes!

I’m sold! The GitHub CLI definitely got me hooked to the various shortcuts that I can perform on the terminal, and quickly get a grasp of what’s going on.

I highly suggest to give it a try, I promise it’s worth the very short learning curve.

Do it: brew install gh

Here, have a slice of pizza 🍕