Skip to content

MissingGhHost

GH_HOST is required for using the gh CLI tool with GH_ENTERPRISE_TOKEN.

Defined by MissingGhTokenRule which supports workflows, actions in the "Default" ruleset along with MissingGhToken.

Description

Using the gh CLI tool requires a GitHub token to be set, and for Enterprise tokens, the GitHub Host must be also set.

GH_ENTERPRISE_TOKEN: an authentication token for API requests to GitHub Enterprise. When setting this, also set GH_HOST. GH_HOST: specify the GitHub hostname for commands that would otherwise assume the "github.com" host [...]. When setting this, also set GH_ENTERPRISE_TOKEN. -- gh help environment

References:

Note: it might be tempting to use GH_HOST: ${{ github.server_url }}, but gh can't handle the protocol part of the URL.

Compliant example

GH_HOST is defined.

example.yml

on: push
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: gh pr list
        env:
          GH_ENTERPRISE_TOKEN: ${{ github.token }}
          GH_HOST: github.example.com

Non-compliant example

GH_HOST is not defined.

example.yml

on: push
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: gh pr list
        env:
          GH_ENTERPRISE_TOKEN: ${{ github.token }}

  • Line 7: Step[#1] in Job[example] should see GH_HOST environment variable when using GH_ENTERPRISE_TOKEN.