Skip to content

fix: write GH_HOST to GITHUB_ENV instead of GITHUB_OUTPUT#22974

Merged
lpcox merged 1 commit intomainfrom
fix/ghes-host-config-github-env
Mar 25, 2026
Merged

fix: write GH_HOST to GITHUB_ENV instead of GITHUB_OUTPUT#22974
lpcox merged 1 commit intomainfrom
fix/ghes-host-config-github-env

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Mar 25, 2026

Fixes #22957

Problem

The ghes-host-config step in compiled workflows wrote GH_HOST to $GITHUB_OUTPUT, but the output was only consumed by user-provided typed steps that the compiler explicitly injected ${{ steps.ghes-host-config.outputs.GH_HOST }} into. This had two issues:

  1. Generated steps (e.g., "Process Safe Outputs", checkout steps) never received GH_HOST — they weren't typed steps with explicit injection
  2. Workflows without user-provided steps had the ghes-host-config step as a complete no-op — the output was written but never read

Fix

Write GH_HOST to $GITHUB_ENV instead of $GITHUB_OUTPUT. This makes GH_HOST automatically available to ALL subsequent steps in the job — both user-provided and generated — without needing explicit per-step injection.

This matches how the main agent job already handles GH_HOST via configure_gh_for_ghe.sh (which writes to GITHUB_ENV).

Changes

  • pkg/workflow/ghes_host_step.go — Write to $GITHUB_ENV instead of $GITHUB_OUTPUT
  • pkg/workflow/compiler_jobs.go — Remove redundant per-step GH_HOST injection (GITHUB_ENV makes it automatic)
  • pkg/workflow/compiler_safe_outputs_job.go — Remove redundant per-step GH_HOST injection
  • pkg/workflow/ghes_host_step_test.go — Update assertions
  • 173 recompiled .lock.yml files

Not a bug: GH_HOST: github.com in Copilot installer

The issue also mentions GH_HOST: github.com hardcoded in the Copilot CLI install step. This is intentional — the Copilot CLI binary is always downloaded from github.com regardless of GHES host. The step-level env override only affects that install step and still takes precedence over GITHUB_ENV.

The ghes-host-config step wrote GH_HOST to $GITHUB_OUTPUT, but the
output was only consumed by user-provided typed steps that the compiler
explicitly injected it into. Generated steps (e.g. Process Safe Outputs)
never received GH_HOST, and workflows without user-provided steps had
the step as a complete no-op.

Fix: write to $GITHUB_ENV so that ALL subsequent steps in the job
automatically inherit GH_HOST. This matches how the main agent job
handles it via configure_gh_for_ghe.sh.

The per-step injection code in compiler_jobs.go and
compiler_safe_outputs_job.go is removed since GITHUB_ENV makes it
redundant. The Copilot installer's step-level GH_HOST: github.com
override still takes precedence (step env > GITHUB_ENV).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 25, 2026 21:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes GHES/GHEC host propagation in compiled workflows by exporting GH_HOST via $GITHUB_ENV (job environment) rather than $GITHUB_OUTPUT (step output), ensuring both generated and user-provided steps receive GH_HOST without per-step injection.

Changes:

  • Update the generated ghes-host-config step to write GH_HOST to $GITHUB_ENV.
  • Remove redundant per-step GH_HOST env injection from compiler paths that previously depended on ${{ steps.ghes-host-config.outputs.GH_HOST }}.
  • Recompile affected workflow lock files to reflect the new propagation mechanism.

Reviewed changes

Copilot reviewed 177 out of 177 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/workflow/ghes_host_step.go Switches GH_HOST export from $GITHUB_OUTPUT to $GITHUB_ENV.
pkg/workflow/compiler_jobs.go Removes redundant per-step GH_HOST injection for custom (frontmatter) jobs.
pkg/workflow/compiler_safe_outputs_job.go Removes redundant per-step GH_HOST injection for user-provided safe-outputs steps.
pkg/workflow/ghes_host_step_test.go Updates assertions to validate $GITHUB_ENV usage instead of $GITHUB_OUTPUT.
.github/workflows/*.lock.yml Recompiled lock workflows reflecting $GITHUB_ENV export and removal of per-step injected GH_HOST.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiled lock files hardcode GH_HOST=github.com and ghes-host-config output is unused

2 participants