Skip to content

Commit f9cd31a

Browse files
committed
feat: Add installation script for GitHub Copilot CLI and update README with environment variable options
1 parent bee45e7 commit f9cd31a

3 files changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
## Optional Environment Variables:
7+
8+
SKIP_INSTALL_COPILOT_CLI="${SKIP_INSTALL_COPILOT_CLI:-}" # Set to 'true' to skip installing Copilot CLI
9+
COPILOT_CLI_VERSION="${COPILOT_CLI_VERSION:-}" # Optional version (ex. 'v0.0.369'); defaults to latest when unset
10+
COPILOT_CLI_PREFIX="${COPILOT_CLI_PREFIX:-}" # Optional install prefix; defaults per official installer
11+
12+
log() {
13+
printf "========== %s ==========%s" "$1" $'\n'
14+
}
15+
16+
err() {
17+
printf "[ ERROR ]: %s%s" "$1" $'\n' >&2
18+
exit 1
19+
}
20+
21+
require_downloader() {
22+
if command -v curl &>/dev/null; then
23+
echo "curl"
24+
return 0
25+
fi
26+
27+
if command -v wget &>/dev/null; then
28+
echo "wget"
29+
return 0
30+
fi
31+
32+
err "Either 'curl' or 'wget' is required to install Copilot CLI"
33+
}
34+
35+
install_copilot_cli() {
36+
if [[ ${SKIP_INSTALL_COPILOT_CLI,,} == "true" ]]; then
37+
log "Skipping Copilot CLI install"
38+
return 0
39+
fi
40+
41+
local downloader
42+
downloader="$(require_downloader)"
43+
44+
log "Installing Copilot CLI (standalone)"
45+
46+
if [[ $downloader == "curl" ]]; then
47+
if [[ $COPILOT_CLI_VERSION || $COPILOT_CLI_PREFIX ]]; then
48+
VERSION="$COPILOT_CLI_VERSION" PREFIX="$COPILOT_CLI_PREFIX" curl -fsSL https://gh.io/copilot-install | bash
49+
else
50+
curl -fsSL https://gh.io/copilot-install | bash
51+
fi
52+
else
53+
if [[ $COPILOT_CLI_VERSION || $COPILOT_CLI_PREFIX ]]; then
54+
VERSION="$COPILOT_CLI_VERSION" PREFIX="$COPILOT_CLI_PREFIX" wget -qO- https://gh.io/copilot-install | bash
55+
else
56+
wget -qO- https://gh.io/copilot-install | bash
57+
fi
58+
fi
59+
60+
if [[ ! $COPILOT_CLI_PREFIX ]]; then
61+
export PATH="$HOME/.local/bin:$PATH"
62+
else
63+
export PATH="$COPILOT_CLI_PREFIX/bin:$PATH"
64+
fi
65+
66+
if ! command -v copilot &>/dev/null; then
67+
err "Copilot CLI install completed but 'copilot' is not on PATH"
68+
fi
69+
70+
copilot --version || true
71+
log "Copilot CLI is available via 'copilot'"
72+
}
73+
74+
install_copilot_cli

.devcontainer/post-script.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
set -e
44
set -o pipefail
55

6+
## Optional Environment Variables:
7+
8+
SKIP_INSTALL_COPILOT_CLI="${SKIP_INSTALL_COPILOT_CLI:-}" # Set to 'true' to skip installing Copilot CLI
9+
COPILOT_CLI_VERSION="${COPILOT_CLI_VERSION:-}" # Optional version (ex. 'v0.0.369'); defaults to latest when unset
10+
COPILOT_CLI_PREFIX="${COPILOT_CLI_PREFIX:-}" # Optional install prefix; defaults per official installer
11+
612
log() {
713
printf "========== %s ==========%s" "$1" $'\n'
814
}
@@ -37,6 +43,8 @@ install_uv() {
3743

3844
install_uv
3945

46+
bash .devcontainer/install-copilot-cli.sh
47+
4048
echo ----------------------------------------------
4149
echo If you want help using the prompt library or list
4250
echo of available prompts, simply type:

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ This template includes an `.agent/` directory containing reusable prompt “comm
6666
- `.agent/instructions/`: “apply-to” instructions that guide how agents write certain file types (e.g. Bash and Bicep)
6767

6868
If you base a new repository on this template, treat `.agent/` as a starting library: keep what helps your team, remove what doesn’t, and add org-specific workflows over time.
69+
70+
## Copilot CLI (devcontainer)
71+
72+
The devcontainer runs a post-create script that installs GitHub Copilot CLI using the official installer (`https://gh.io/copilot-install`).
73+
74+
Optional environment variables:
75+
76+
- `SKIP_INSTALL_COPILOT_CLI=true`: skip installing Copilot CLI
77+
- `COPILOT_CLI_VERSION=vX.Y.Z`: install a specific version tag (defaults to latest)
78+
- `COPILOT_CLI_PREFIX=/some/path`: install to a custom prefix (defaults per installer)

0 commit comments

Comments
 (0)