Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ jobs:
contents: read
steps:
- name: Install gh-aw extension
run: curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash
run: |
INSTALL_SCRIPT=$(mktemp)
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/copilot-token-audit.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion .github/workflows/copilot-token-optimizer.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/shared/mcp/gh-aw.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
# Install gh-aw if not already available
if ! gh aw --version >/dev/null 2>&1; then
echo "Installing gh-aw extension..."
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash
gh extension install github/gh-aw
fi
gh aw --version
# Copy the gh-aw binary to ${RUNNER_TEMP}/gh-aw for MCP server containerization
Expand Down
6 changes: 5 additions & 1 deletion create.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ gh extension upgrade aw
to upgrade to latest. If it is not installed, run the installation script from the main branch of the gh-aw repository:

```bash
curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh | bash
INSTALL_SCRIPT=$(mktemp)
curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
```

**What this does**: Downloads and installs the gh-aw binary to `~/.local/share/gh/extensions/gh-aw/`
Expand Down
6 changes: 5 additions & 1 deletion debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ gh extension upgrade aw
to upgrade to latest. If it is not installed, run the installation script from the main branch of the gh-aw repository:

```bash
curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh | bash
INSTALL_SCRIPT=$(mktemp)
curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
```

**What this does**: Downloads and installs the gh-aw binary to `~/.local/share/gh/extensions/gh-aw/`
Expand Down
6 changes: 5 additions & 1 deletion install.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Configure this repository to use agentic workflows by:
Run the installation script from the main branch of the gh-aw repository:

```bash
curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh | bash
INSTALL_SCRIPT=$(mktemp)
curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
```

**What this does**: Downloads and installs the gh-aw binary to `~/.local/share/gh/extensions/gh-aw/`
Expand Down
20 changes: 16 additions & 4 deletions pkg/cli/copilot_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
`, actionRepo, actionRef, version)
}

// Default (dev/script mode): use curl to download install script
// Default (dev/script mode): download install script to temp file and execute
return `name: "Copilot Setup Steps"

# This workflow configures the environment for GitHub Copilot Agent with gh-aw MCP server
Expand All @@ -104,7 +104,11 @@ jobs:
steps:
- name: Install gh-aw extension
run: |
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash
INSTALL_SCRIPT=$(mktemp)
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
`
}

Expand All @@ -130,7 +134,11 @@ jobs:
steps:
- name: Install gh-aw extension
run: |
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash
INSTALL_SCRIPT=$(mktemp)
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
`

// CopilotWorkflowStep represents a GitHub Actions workflow step for Copilot setup scaffolding
Expand Down Expand Up @@ -287,7 +295,11 @@ func renderCopilotSetupUpdateInstructions(filePath string, actionMode workflow.A
} else {
fmt.Fprintln(os.Stderr, " - name: Install gh-aw extension")
fmt.Fprintln(os.Stderr, " run: |")
fmt.Fprintln(os.Stderr, " curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash")
fmt.Fprintln(os.Stderr, " INSTALL_SCRIPT=$(mktemp)")
fmt.Fprintln(os.Stderr, " curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o \"$INSTALL_SCRIPT\"")
fmt.Fprintln(os.Stderr, " chmod +x \"$INSTALL_SCRIPT\"")
fmt.Fprintln(os.Stderr, " \"$INSTALL_SCRIPT\"")
fmt.Fprintln(os.Stderr, " rm -f \"$INSTALL_SCRIPT\"")
}
fmt.Fprintln(os.Stderr)
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/cli/copilot_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func TestEnsureCopilotSetupSteps(t *testing.T) {
if !strings.Contains(string(content), "curl -fsSL") {
t.Error("Expected workflow to contain curl command")
}
if strings.Contains(string(content), "install-gh-aw.sh | bash") {
t.Error("Expected workflow to NOT pipe install script directly to bash (use temp file instead)")
}
},
},
{
Expand Down Expand Up @@ -524,6 +527,11 @@ func TestEnsureCopilotSetupSteps_DevMode(t *testing.T) {
t.Error("Expected copilot-setup-steps.yml to use install-gh-aw.sh in dev mode")
}

// Verify it uses the secure temp-file pattern, not pipe-to-bash
if strings.Contains(contentStr, "install-gh-aw.sh | bash") {
t.Error("Expected copilot-setup-steps.yml to NOT pipe install script directly to bash (use temp file instead)")
}

// Verify it doesn't use actions/setup-cli
if strings.Contains(contentStr, "actions/setup-cli") {
t.Error("Expected copilot-setup-steps.yml to NOT use actions/setup-cli in dev mode")
Expand Down Expand Up @@ -604,6 +612,9 @@ func TestEnsureCopilotSetupSteps_CreateWithDevMode(t *testing.T) {
if !strings.Contains(contentStr, "install-gh-aw.sh") {
t.Errorf("Expected install-gh-aw.sh reference in dev mode")
}
if strings.Contains(contentStr, "install-gh-aw.sh | bash") {
t.Errorf("Expected dev mode to NOT pipe install script directly to bash (use temp file instead)")
}
if strings.Contains(contentStr, "actions/setup-cli") {
t.Errorf("Did not expect actions/setup-cli in dev mode")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/devcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func ensureDevcontainerConfig(verbose bool, additionalRepos []string) error {

// Update postCreateCommand if not set or if it doesn't include gh-aw install
if config.PostCreateCommand == "" || !strings.Contains(config.PostCreateCommand, "install-gh-aw.sh") {
ghAwInstall := "curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash"
ghAwInstall := "INSTALL_SCRIPT=$(mktemp) && curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o \"$INSTALL_SCRIPT\" && chmod +x \"$INSTALL_SCRIPT\" && \"$INSTALL_SCRIPT\" && rm -f \"$INSTALL_SCRIPT\""
if config.PostCreateCommand == "" {
config.PostCreateCommand = ghAwInstall
} else {
Expand Down Expand Up @@ -185,7 +185,7 @@ func ensureDevcontainerConfig(verbose bool, additionalRepos []string) error {
"ghcr.io/devcontainers/features/github-cli:1": map[string]any{},
"ghcr.io/devcontainers/features/copilot-cli:latest": map[string]any{},
},
PostCreateCommand: "curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash",
PostCreateCommand: "INSTALL_SCRIPT=$(mktemp) && curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o \"$INSTALL_SCRIPT\" && chmod +x \"$INSTALL_SCRIPT\" && \"$INSTALL_SCRIPT\" && rm -f \"$INSTALL_SCRIPT\"",
}

if verbose {
Expand Down
18 changes: 14 additions & 4 deletions pkg/parser/yaml_import_copilot_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestExtractStepsFromCopilotSetup(t *testing.T) {
"steps": []any{
map[string]any{
"name": "Install gh-aw extension",
"run": "curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash",
"run": "INSTALL_SCRIPT=$(mktemp)\ncurl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o \"$INSTALL_SCRIPT\"\nchmod +x \"$INSTALL_SCRIPT\"\n\"$INSTALL_SCRIPT\"\nrm -f \"$INSTALL_SCRIPT\"\n",
},
map[string]any{
"name": "Checkout code",
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestExtractStepsFromCopilotSetup_StripsCheckoutStep(t *testing.T) {
"steps": []any{
map[string]any{
"name": "Install gh-aw extension",
"run": "curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash",
"run": "INSTALL_SCRIPT=$(mktemp)\ncurl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o \"$INSTALL_SCRIPT\"\nchmod +x \"$INSTALL_SCRIPT\"\n\"$INSTALL_SCRIPT\"\nrm -f \"$INSTALL_SCRIPT\"\n",
},
map[string]any{
"name": "Checkout code",
Expand Down Expand Up @@ -318,7 +318,12 @@ jobs:
contents: read
steps:
- name: Install gh-aw extension
run: curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash
run: |
INSTALL_SCRIPT=$(mktemp)
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
Expand Down Expand Up @@ -411,7 +416,12 @@ jobs:
contents: read
steps:
- name: Install gh-aw extension
run: curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash
run: |
INSTALL_SCRIPT=$(mktemp)
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand Down
7 changes: 6 additions & 1 deletion pkg/workflow/copilot_setup_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ jobs:
contents: read
steps:
- name: Install gh-aw extension
run: curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash
run: |
INSTALL_SCRIPT=$(mktemp)
curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh -o "$INSTALL_SCRIPT"
chmod +x "$INSTALL_SCRIPT"
"$INSTALL_SCRIPT"
rm -f "$INSTALL_SCRIPT"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand Down