---
url: https://ws.kloudkit.com/tools/github-cli.md
description: >-
  Install the GitHub CLI in Kloud Workspace with the gh feature, and sign it in
  from a token when a new container starts.
---

# GitHub CLI&#x20;

::: warning Optional Feature

This feature is not preinstalled in Kloud Workspace.
Install it with the [features system](/tools/features) first.

:::

![GitHub logo](/icons/github.svg){.doc-image width=150px}

The `gh` feature installs the GitHub CLI with its shell completion.
With a token set, the workspace signs `gh` in when a new container starts.

## Installation

Install `gh` using the [features](/tools/features) system:

```sh
# Manual installation
ws-cli feature install gh

# Or at boot time
docker run \
  -e WS_FEATURES_ADDITIONAL_FEATURES="gh" \
  ghcr.io/kloudkit/workspace:v0.6.2
```

The `gh` feature is available from the [feature store](/tools/feature-store).

## Sign In with a Token

Provide a GitHub personal access token:

```sh{2}
docker run \
  -e WS_AUTH_GITHUB_TOKEN="<token>" \
  -e WS_FEATURES_ADDITIONAL_FEATURES="gh" \
  ghcr.io/kloudkit/workspace:v0.6.2
```

When a new container starts, the workspace installs the boot-time features first,
then passes the token to `gh auth login --with-token`.
If the login fails, the workspace logs a warning and keeps starting.
When `gh` is not installed, the token step is skipped.

The workspace removes `WS_AUTH_GITHUB_TOKEN` from the editor's environment,
so terminals opened in the editor do not see the token.

::: tip

`WS_AUTH_GITHUB_TOKEN` is a secret.

Besides the literal value, you can supply it as a `file:` reference *(`file:/path/to/token`)* or mount
it at `/run/secrets/workspace/auth/github_token`.

:::

## After a Manual Install

The token sign-in runs only when a new container starts.
After `ws-cli feature install gh` in a running workspace, sign in yourself:

```sh
gh auth login
```

## Git over HTTPS

The token signs in `gh` only.
It does not set up HTTPS authentication for `git` in the terminal:
use SSH or a credential helper, as described on the [Git](/tools/git) page.
