Skip to content

Instantly share code, notes, and snippets.

@dingp
Created July 2, 2024 00:55
Show Gist options
  • Save dingp/e35f572ebc5b1e25834bca0019216149 to your computer and use it in GitHub Desktop.
Save dingp/e35f572ebc5b1e25834bca0019216149 to your computer and use it in GitHub Desktop.

Using GitHub CLI on Perlmutter

Installation

  1. Go to the release page of cli/cli, and get the compatible build for Perlmutter. The latest version as of July 1, 2024 is GitHub CLI 2.52.0 linux amd64
  2. Untar the file, and move the single binary executable gh to path which is included in the list of the env PATH, or add the path to it in your $HOME/.bashrc.ext;
  3. Similarly, move the share/man subdiretory into a place already pointed to by the env MANPATH, or the new path to $HOME/.bashrc.ext;
  4. Add bash (or other shell) completion by adding eval "$(gh completion -s bash)" into $HOME/.bashrc.ext. After opening a new terminal, you would be able to test the installation with which gh, man gh and use the tab key for sub-command completion (tab once to auto complete the command, tab twice to list all possible completions).

My additions to $HOME/.bashrc look like:

 export PATH=$HOME/bin:$PATH
 export MANPATH="$(manpath -g):$HOME/.local/share/man"
 eval "$(gh completion -s bash)"

Authentication

Create a GitHub Personal Access Token, and give it proper scopes and expiration date. Save the token in a secure place. On a Perlmutter login node, run gh auth login and follow the prompt to choose "GitHub.com" --> "HTTPS" --> "Paste an authentication token".

Usage example -- Gist gh gist <sub-command>

# Relevant sub-commands
$ gh gist
clone   (Clone a gist locally)
delete  (Delete a gist)
list    (List your gists)
view    (View a gist)
create  (Create a new gist)
edit    (Edit one of your gists)
rename  (Rename a file in a gist)

$ gh gist list

# publish file 'hello.py' as a public gist
$ gh gist create --public hello.py

# create a gist with a description
$ gh gist create hello.py -d "my Hello-World program in Python"

# create a gist containing several files
$ gh gist create hello.py world.py cool.txt

# read from standard input to create a gist
$ gh gist create -

# create a gist from output piped from another command
$ cat cool.txt | gh gist create

Usage example -- GitHub Actions gh workflow <sub-command> [-R <org/repo>]

# Relevant sub-commands

$ gh workflow
disable  (Disable a workflow)
list     (List workflows)
view     (View the summary of a workflow)
enable   (Enable a workflow)
run      (Run a workflow by creating a workflow_dispatch event)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment