MCPcopy Create free account
hub / github.com/github/gh-aw / generateAgenticWorkflowsInstallStep

Function generateAgenticWorkflowsInstallStep

pkg/workflow/mcp_setup_generator.go:178–226  ·  view source on GitHub ↗
(c *Compiler, yaml *strings.Builder, hasAgenticWorkflows bool, workflowData *WorkflowData)

Source from the content-addressed store, hash-verified

176}
177
178func generateAgenticWorkflowsInstallStep(c *Compiler, yaml *strings.Builder, hasAgenticWorkflows bool, workflowData *WorkflowData) {
179 if !hasAgenticWorkflows {
180 return
181 }
182
183 cliVersion := resolveAgenticWorkflowsCLIVersion(c, workflowData)
184 effectiveToken := getEffectiveGitHubToken("")
185 actionRepo := GitHubActionsOrgRepo + "/setup-cli"
186 installStep, err := generateGhAwSetupStep(ghAwSetupStepConfig{
187 actionMode: c.actionMode,
188 cliVersion: cliVersion,
189 actionRepo: actionRepo,
190 fallbackActionRefTag: cliVersion,
191 workflowData: workflowData,
192 withFields: map[string]string{
193 "github-token": effectiveToken,
194 },
195 })
196 if err != nil {
197 mcpSetupGeneratorLog.Printf("Failed to resolve pinned setup-cli action reference for %s@%s: %v", actionRepo, cliVersion, err)
198 }
199 for _, line := range installStep {
200 yaml.WriteString(line + "\n")
201 }
202 yaml.WriteString(" - name: Copy gh-aw binary for MCP server\n")
203 yaml.WriteString(" run: |\n")
204 yaml.WriteString(" gh aw --version\n")
205 yaml.WriteString(" # Copy the gh-aw binary to ${RUNNER_TEMP}/gh-aw for MCP server containerization\n")
206 yaml.WriteString(" mkdir -p \"${RUNNER_TEMP}/gh-aw\"\n")
207 yaml.WriteString(" GH_AW_BIN=\"\"\n")
208 yaml.WriteString(" GH_AW_BIN=$(command -v gh-aw 2>/dev/null) || true\n")
209 yaml.WriteString(" if [ -z \"$GH_AW_BIN\" ]; then\n")
210 yaml.WriteString(" GH_AW_BIN=$(find \"${HOME}/.local/share/gh/extensions/gh-aw\" -name 'gh-aw' -type f 2>/dev/null | head -1) || true\n")
211 yaml.WriteString(" fi\n")
212 yaml.WriteString(" if [ -z \"$GH_AW_BIN\" ] && [ -n \"${GH_CONFIG_DIR:-}\" ]; then\n")
213 yaml.WriteString(" GH_AW_BIN=$(find \"${GH_CONFIG_DIR}/extensions/gh-aw\" -name 'gh-aw' -type f 2>/dev/null | head -1) || true\n")
214 yaml.WriteString(" fi\n")
215 yaml.WriteString(" if [ -z \"$GH_AW_BIN\" ] && [ -f \"${GITHUB_WORKSPACE}/gh-aw\" ]; then\n")
216 yaml.WriteString(" GH_AW_BIN=\"${GITHUB_WORKSPACE}/gh-aw\"\n")
217 yaml.WriteString(" fi\n")
218 yaml.WriteString(" if [ -n \"$GH_AW_BIN\" ] && [ -f \"$GH_AW_BIN\" ]; then\n")
219 yaml.WriteString(" cp \"$GH_AW_BIN\" \"${RUNNER_TEMP}/gh-aw/gh-aw\"\n")
220 yaml.WriteString(" chmod +x \"${RUNNER_TEMP}/gh-aw/gh-aw\"\n")
221 yaml.WriteString(" echo \"Copied gh-aw binary to ${RUNNER_TEMP}/gh-aw/gh-aw\"\n")
222 yaml.WriteString(" else\n")
223 yaml.WriteString(" echo \"::error::Failed to find gh-aw binary for MCP server\"\n")
224 yaml.WriteString(" exit 1\n")
225 yaml.WriteString(" fi\n")
226}
227
228func resolveAgenticWorkflowsCLIVersion(c *Compiler, workflowData *WorkflowData) string {
229 cliVersion := c.actionTag

Callers 1

generateMCPSetupMethod · 0.85

Calls 4

getEffectiveGitHubTokenFunction · 0.85
generateGhAwSetupStepFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected