# gh

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> The GitHub CLI, the install companion to the gh tool configuration.


Installs the GitHub CLI (`gh`).

```yaml
devtools:
  - name: gh
```

The `version` field is not used by this recipe.

## Updates

The GitHub CLI comes from GitHub's package repository on Debian and Ubuntu, and from
Alpine's packages on Alpine. It moves with the
[operating system updates](https://docs-stg.ringleader.dev/reference/tools/devtools/#operating-system-updates) the workstation applies.

## Purpose

On **Debian and Ubuntu** it declares GitHub's official apt repository and signing key,
then installs the `gh` package through the normal repository and package phases. On
**Alpine** it installs the distribution's `github-cli` package.

## Authentication

Installing `gh` leaves it unauthenticated. Pair it with the
[`gh` toolconfig](https://docs-stg.ringleader.dev/reference/tools/tool-configuration/gh/), which writes an
authenticated login from a Secret without setting `GH_TOKEN`, so
`gh auth login`, `logout` and `switch` keep working inside the workstation.

## Example

An opt-in add-on layer that installs `gh` and authenticates it from your own token
Secret:

```yaml
apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
  name: gh-cli
  namespace: local
spec:
  selector:
    matchLabels:
      owner: ada
  priority: 200
  devtools:
    - name: gh
  toolconfigs:
    - id: gh
      name: gh
      config:
        token: "${secret:gh-token/token}"
```

Create the Secret first; with an unresolved reference the workstation fails with a
clear message:

```bash
rl secret create gh-token -n local --from-string token=<your-token>
```

## Notes

- A fine-grained token that is read-only for repository contents is enough for
  `gh pr`, `gh run`, and `gh api`. Pushes can still ride SSH: the toolconfig's
  `gitProtocol` defaults to `ssh`.
- Alternatively, authenticate interactively with `gh auth login`. With
  [Browser sign-in](https://docs-stg.ringleader.dev/workstations/connectivity/browser-sign-in/) turned on, the
  device-code URL opens on your computer.

