Skip to content

fix: configure_gh_for_ghe.sh should unset stale GH_HOST on github.com #24217

@lpcox

Description

@lpcox

Problem

When configure_gh_for_ghe.sh detects the host is github.com, it returns early without unsetting GH_HOST:

if [ "$github_host" = "github.com" ]; then
  echo "Using public GitHub (github.com) - no additional gh configuration needed"
  return 0   # ← exits without touching GH_HOST
fi

If GH_HOST was already set in the environment (by a prior step, runner config, or stale state), the early return leaves the stale value in place. When gh pr checkout runs later, it fails with:

none of the git remotes configured for this repository correspond to the GH_HOST environment variable

Triggered by: https://github.com/fsprojects/FSharp.Control.AsyncSeq/actions/runs/23929188570/job/69792652319#step:13:93

Root cause

configure_gh_for_ghe.sh assumes that for github.com, GH_HOST is either unset or correct. But if it has a stale/wrong value, the script does nothing to correct it.

Proposed fix

For github.com, explicitly unset GH_HOST (or set it to github.com) to prevent stale values from breaking downstream gh CLI commands:

if [ "$github_host" = "github.com" ]; then
  echo "Using public GitHub (github.com) - no additional gh configuration needed"
  # Clear any stale GH_HOST to prevent gh CLI mismatches
  if [ -n "${GH_HOST:-}" ] && [ "${GH_HOST}" != "github.com" ]; then
    echo "Clearing stale GH_HOST=${GH_HOST}"
    echo "GH_HOST=github.com" >> "$GITHUB_ENV"
  fi
  return 0
fi

Files to modify

  • actions/setup/sh/configure_gh_for_ghe.sh — Add GH_HOST cleanup for github.com path

Related

Metadata

Metadata

Labels

bugSomething isn't workingcli

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions