Skip to content

Add GitHub Copilot CLI to hosted runner images#14045

Draft
salmanmkc wants to merge 1 commit into
actions:mainfrom
salmanmkc:salmanmkc/install-copilot-cli
Draft

Add GitHub Copilot CLI to hosted runner images#14045
salmanmkc wants to merge 1 commit into
actions:mainfrom
salmanmkc:salmanmkc/install-copilot-cli

Conversation

@salmanmkc
Copy link
Copy Markdown

@salmanmkc salmanmkc commented May 13, 2026

Install @github/copilot into the agent tool cache during image bake for Ubuntu 24.04 and 26.04. The CLI is staged at $AGENT_TOOLSDIRECTORY/copilot-cli/<version>/x64/ with the matching x64.complete marker file, so a runtime consumer using @actions/tool-cache can find it via tc.find("copilot-cli", ...) and expose it on PATH with core.addPath.

This enables agentic workflows that use the Copilot engine to skip the runtime npm install step on a cache hit, reducing workflow startup time. The toolcache version is read from https://raw.githubusercontent.com/github/gh-aw-actions/main/.github/aw/compat.json (the agentic-workflows compatibility matrix), specifically the max-agent value on the catch-all row.

Changes

  • images/ubuntu/scripts/build/install-copilot-cli.sh — fetch the toolcache version from compat.json, install via npm install -g --prefix <toolcache>/x64/, write x64.complete marker. Hard-fails the bake on fetch/parse failure (matches install-awf.sh semantics).
  • images/ubuntu/scripts/tests/Tools.Tests.ps1 — Pester test verifying the toolcache layout (/opt/hostedtoolcache/copilot-cli/*/x64/bin/copilot, x64.complete marker present). Mirrors the existing AWF test block.
  • images/ubuntu/templates/build.ubuntu-24_04.pkr.hcl — invoke install-copilot-cli.sh in the build (after install-nodejs.sh so npm is available).
  • images/ubuntu/templates/build.ubuntu-26_04.pkr.hcl — same.

Why toolcache instead of system PATH

A runtime consumer needs to (a) pick a specific version that satisfies a semver range and (b) ensure the binary is on PATH for the agent step. The standard pattern for both is @actions/tool-cache: tc.find("copilot-cli", range) returns the cached path, core.addPath(<path>/bin) exposes it. That requires the on-disk layout to be $RUNNER_TOOL_CACHE/<tool>/<version>/<arch>/ with a .complete marker — which is exactly what this script produces. AWF (install-awf.sh in this same repo) uses the same pattern.

Backward compatibility

This change is no-op for workflows that don't use @actions/tool-cache to find the Copilot CLI. The bake step neither shadows nor removes anything from the global PATH (the previous global npm install -g location is replaced because nothing else needs the binary there). Workflows that today install Copilot CLI via npm install -g at runtime keep doing so unchanged.

Copilot AI review requested due to automatic review settings May 13, 2026 14:34
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 adds the GitHub Copilot CLI to the Ubuntu 24.04 and 26.04 hosted runner image bake, so workflows can use copilot without installing it at runtime.

Changes:

  • Add a new Ubuntu build script to install @github/copilot globally via npm.
  • Add a Pester test to validate copilot --version succeeds (skipped on Ubuntu 22.04).
  • Wire the install script into the Ubuntu 24.04 and 26.04 Packer build templates.
Show a summary per file
File Description
images/ubuntu/templates/build.ubuntu-26_04.pkr.hcl Adds the Copilot CLI install step to the Ubuntu 26.04 image build script list.
images/ubuntu/templates/build.ubuntu-24_04.pkr.hcl Adds the Copilot CLI install step to the Ubuntu 24.04 image build script list.
images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1 Adds a Pester validation that copilot --version returns exit code 0 (skipped on 22.04).
images/ubuntu/scripts/build/install-copilot-cli.sh New installer that installs the Copilot CLI via npm and invokes the corresponding tests.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment on lines 111 to 116
"${path.root}/../scripts/build/install-cmake.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh",
"${path.root}/../scripts/build/install-awf.sh",
"${path.root}/../scripts/build/install-copilot-cli.sh",
"${path.root}/../scripts/build/install-container-tools.sh",
"${path.root}/../scripts/build/install-dotnetcore-sdk.sh",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 921ae04 \u2014 install-copilot-cli.sh now runs right after install-nodejs.sh in both Ubuntu 24.04 and 26.04 provisioner lists. While I was in there I also pinned the install to a known-good version pulled from the agentic workflows compatibility matrix (raw.githubusercontent.com/github/gh-aw-actions/main/.github/aw/compat.json), so the baked tool-cache version matches what the runtime setup action will resolve to. Falls back to latest on any fetch failure so an outage on raw.githubusercontent.com does not block the image bake.

Comment on lines 108 to 114
"${path.root}/../scripts/build/install-aws-tools.sh",
"${path.root}/../scripts/build/install-clang.sh",
"${path.root}/../scripts/build/install-cmake.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh",
"${path.root}/../scripts/build/install-awf.sh",
"${path.root}/../scripts/build/install-copilot-cli.sh",
"${path.root}/../scripts/build/install-container-tools.sh",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same fix in 921ae04 \u2014 see the 24.04 reply above for the full rationale.

@salmanmkc salmanmkc marked this pull request as draft May 15, 2026 00:30
@salmanmkc salmanmkc marked this pull request as ready for review May 22, 2026 17:11
Install @github/copilot into the agent tool cache during image bake
for Ubuntu 24.04 and 26.04, pinned to the version validated by the
gh-aw agent compatibility matrix.

The CLI is staged at $AGENT_TOOLSDIRECTORY/copilot-cli/<version>/x64/
with the matching x64.complete marker file, so a runtime consumer
using @actions/tool-cache can find it via tc.find("copilot-cli", ...)
and expose it on PATH with core.addPath. This is the standard hosted-
runner toolcache layout used by install-awf.sh and install-codeql-
bundle.sh in the same directory.

Version resolution: fetch
https://raw.githubusercontent.com/github/gh-aw-actions/main/.github/aw/compat.json
and read the catch-all max-agent value (max-gh-aw == "*"). This is
the highest Copilot CLI version validated against the current gh-aw
release line. Hard-fails the bake on fetch/parse failure, multiple
catch-all rows, or non-semver values (matches the install-awf.sh
fail-fast pattern; we'd rather rebuild later than ship an
unvalidated version).

Tightens the curl invocation with --proto '=https' --proto-redir
'=https' to prevent silent fall-through to a plaintext redirect if
raw.githubusercontent.com were ever to 302 elsewhere.

Pester test in Tools.Tests.ps1 verifies the toolcache layout
(directory present, bin/copilot exists, .complete marker present),
mirroring the existing AWF test block.

Backward compatible: the bake step neither shadows nor removes
anything from the global PATH, so workflows that today install the
CLI at runtime keep working unchanged.
@salmanmkc salmanmkc force-pushed the salmanmkc/install-copilot-cli branch from cdc05fd to 95d1aca Compare May 26, 2026 11:59
@salmanmkc salmanmkc marked this pull request as draft May 26, 2026 12:00
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.

2 participants