Skip to content

Add GitHub Copilot CLI to hosted runner images#14045

Open
salmanmkc wants to merge 3 commits into
actions:mainfrom
salmanmkc:salmanmkc/install-copilot-cli
Open

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

Conversation

@salmanmkc
Copy link
Copy Markdown

Install @github/copilot via npm during image bake for Ubuntu 24.04 and 26.04. This pre-installs the Copilot CLI so agentic workflows using the Copilot engine do not need to install it at runtime, reducing workflow startup time.

Changes

  • images/ubuntu/scripts/build/install-copilot-cli.sh — install script using npm install -g @github/copilot --ignore-scripts
  • images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1 — Pester test verifying copilot --version returns 0
  • images/ubuntu/templates/build.ubuntu-24_04.pkr.hcl — add to 24.04 image build
  • images/ubuntu/templates/build.ubuntu-26_04.pkr.hcl — add to 26.04 image build

Install @github/copilot via npm during image bake for Ubuntu 24.04
and 26.04. This pre-installs the Copilot CLI so agentic workflows
using the Copilot engine do not need to install it at runtime,
reducing workflow startup time.

- Add install-copilot-cli.sh install script
- Add Copilot CLI test to CLI.Tools.Tests.ps1
- Add to 24.04 and 26.04 Packer templates
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
The previous version installed Copilot CLI before Node.js, which would
fail on a clean image build because npm doesn't exist until install-
nodejs.sh runs. Move the script down past install-nodejs.sh in both
Ubuntu 24.04 and 26.04 provisioner lists so npm is available.

Pin the install to the catch-all max-agent version published in the
GitHub agentic workflows compatibility matrix at
https://raw.githubusercontent.com/github/gh-aw-actions/main/.github/aw/compat.json
This is the highest Copilot CLI version validated against the current
agentic workflows release line, so workflows that resolve to the same
matrix entry hit the baked tool-cache version on a cache hit instead
of triggering a runtime install.

Falls back to 'latest' on any fetch failure (network, 5xx, malformed
JSON), so a raw.githubusercontent.com outage doesn't block the image
bake. jq is already available because configure-apt.sh installs it
earlier in the provisioner chain.
@salmanmkc salmanmkc marked this pull request as ready for review May 22, 2026 17:11
Previously this script fell back to installing the npm `latest` tag if
the compat.json fetch or parse failed. That fallback silently bakes an
unvalidated Copilot CLI version into the runner image when the matrix
is the documented single source of truth for which version is approved.
It also means a transient network blip during image bake can ship an
arbitrarily newer version that has not been validated.

Replace the silent fallback with fail-fast behaviour matching the
install-awf.sh pattern:

- Exit 1 with a clear error if the compat.json fetch fails.
- Exit 1 with a clear error if the catch-all max-agent row is missing
  (use jq -e so a missing/null result returns non-zero instead of
  producing an empty version string).
- Exit 1 if the catch-all selector returns more than one row, with the
  duplicates printed so the matrix author can fix it.
- Exit 1 if the resolved value is not a valid SemVer (defends against
  malformed matrix entries and injection-shaped values like
  '1.0.48; rm -rf /').

Also tighten 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.

Verified against 8 cases: happy path, valid prerelease, curl failure,
malformed JSON, missing catch-all row, multiple catch-all rows,
non-semver value, and an injection-shaped value. Happy paths exit 0;
all failure modes exit 1 with descriptive errors.
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