-
Notifications
You must be signed in to change notification settings - Fork 18
GHES: Auto-inject GH_HOST in agent container when GHES detected #1302
Copy link
Copy link
Closed
Description
Problem
When agentic workflows run on GHES, the gh CLI inside the agent container defaults to targeting github.com. Any gh commands (e.g., fetching repo data, creating PRs) fail with "Could not resolve to a Repository" errors.
Users must manually add a workflow step to extract the hostname from GITHUB_SERVER_URL and set GH_HOST via GITHUB_ENV.
Proposal
When GITHUB_SERVER_URL is not https://github.com (or engine.api-target is set):
- Automatically set
GH_HOSTin the agent container environment - Extract hostname from
GITHUB_SERVER_URL(striphttps://prefix) - Inject early in the workflow via
GITHUB_ENVso all subsequent steps pick it up
Workaround
We added this step manually to our lock file:
- name: Configure gh for GHE
run: |
SERVER_URL="${GITHUB_SERVER_URL}"
GHE_HOST="${SERVER_URL#https://}"
echo "GH_HOST=${GHE_HOST}" >> "$GITHUB_ENV"
env:
GITHUB_SERVER_URL: ${{ github.server_url }}This should be built in.
Related
- GHES: Wizard should auto-detect GHES and configure GH_HOST, api-target, and allowed domains gh-aw#20965 — Wizard should auto-detect GHES
- GHES: gh aw audit should auto-detect GHES and set GH_HOST gh-aw#20966 — Audit should auto-detect GHES
Reactions are currently unavailable
Metadata
Metadata
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.