Setting up GH

Purpose

These instructions describe the process for setting up GH commands on gadi. These commands make it easier to interface with githib but an initial setup is required.

Prerequisites

  1. a githib account
  2. a login to gadi
    1. You need to have an NCI account and to join project vk83.

gh commands

gh is included in payu modules supported by ACCESS-NRI. As long as the payucommand is available gh should be also.

This is how you make the payu command available:

module use /g/data/vk83/modules
module load payu 

Setup

To authorise with GitHub:

gh auth login

This will prompt for a series of responses. Select the responses used below:

? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? 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... 

At this point you will get an error opening a browser on gadi:

! Failed opening a web browser at https://github.com/login/device
  exec: "xdg-open,x-www-browser,www-browser,wslview": executable file not found in $PATH
  Please try entering the URL in your browser manually

So open Sign in to GitHub · GitHub in your browser, authenticate with GitHub if you’re not already logged in, copy the one-time code from your terminal window and paste it in. Scroll down the page and click “authorise”. Then authentication should complete:

âś“ Authentication complete.
- gh config set -h github.com git_protocol https
âś“ Configured git protocol
! Authentication credentials saved in plain text
âś“ Logged in as xxxxxxxxxxx

To check status use gh auth status

$ gh auth status
github.com
  âś“ Logged in to github.com account xxxxxxxxx (/home/XXX/xxxXXX/.config/gh/hosts.yml)
  - Active account: true
  - Git operations protocol: https
  - Token: gho_************************************
  - Token scopes: 'gist', 'read:org', 'repo'
1 Like

Hi @helen,

Thank you for this useful guide!

I don’t think gh is available as a default on Gadi.
I know an instance is available in the vk83/payu environment, but I am not sure that is the best one to use (for example if I don’t want any of the other dependencies in the payu environment but I’m only interested in gh).
Which environment/module do you suggest using for it?

Thanks @atteggiani. I am recommending using the payu environment (and have added this) as this is the only one I know that is readily available.

1 Like

Thank you @helen.

I find loading the entire payu environment only to be using gh a bit unnecessary (gh is often needed by people that might even never use payu).

Could it be helpful to create a gh module (in vk83), containing only the gh executable, so people only needing gh could do something like:

module load gh

Currently the payu evironment is in a singularity container, so the gh executable cannot be used without loading the module.
For example, with the payu module loaded, the command

which gh

returns /g/data/vk83/apps/conda_scripts/payu-1.1.6.d/bin/gh.

But without payu loaded (if payu has never been loaded within the session, otherwise the singularity instance would have been launched anyway), if you try running:

/g/data/vk83/apps/conda_scripts/payu-1.1.6.d/bin/gh help 

you get

/g/data/vk83/apps/conda_scripts/payu-1.1.6.d/bin/gh: line 121: /home/565/dm5220/miniconda3/bin/conda/envs/payu-1.1.6/bin/gh: Not a directory
/g/data/vk83/apps/conda_scripts/payu-1.1.6.d/bin/gh: line 121: exec: /home/565/dm5220/miniconda3/bin/conda/envs/payu-1.1.6/bin/gh: cannot execute: Not a directory

Is there any “easy” way to make gh available without loading payu?
@jo-basevi