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

Method generateCrushConfigStep

pkg/workflow/crush_engine.go:158–180  ·  view source on GitHub ↗

generateCrushConfigStep writes .crush.json with all permissions set to allow to prevent CI hanging on permission prompts.

(_ *WorkflowData)

Source from the content-addressed store, hash-verified

156// generateCrushConfigStep writes .crush.json with all permissions set to allow
157// to prevent CI hanging on permission prompts.
158func (e *CrushEngine) generateCrushConfigStep(_ *WorkflowData) GitHubActionStep {
159 // Build the config JSON with all permissions set to allow
160 // OpenCode/Crush uses "permission" (singular) — "permissions" (plural) is silently ignored.
161 // "external_directory" must be "allow" in non-interactive CI mode (defaults to "ask" → implicit deny).
162 configJSON := `{"agent":{"build":{"permission":{"bash":"allow","edit":"allow","read":"allow","glob":"allow","grep":"allow","write":"allow","webfetch":"allow","websearch":"allow","external_directory":"allow"}}}}`
163
164 // Shell command to write or merge the config with restrictive permissions
165 command := fmt.Sprintf(`umask 077
166mkdir -p "$GITHUB_WORKSPACE"
167CONFIG="$GITHUB_WORKSPACE/.crush.json"
168BASE_CONFIG='%s'
169if [ -f "$CONFIG" ]; then
170 MERGED=$(jq -n --argjson base "$BASE_CONFIG" --argjson existing "$(cat "$CONFIG")" '$existing * $base')
171 echo "$MERGED" > "$CONFIG"
172else
173 echo "$BASE_CONFIG" > "$CONFIG"
174fi
175chmod 600 "$CONFIG"`, configJSON)
176
177 stepLines := []string{" - name: Write Crush Config"}
178 stepLines = FormatStepWithCommandAndEnv(stepLines, command, nil)
179 return GitHubActionStep(stepLines)
180}

Callers 1

GetExecutionStepsMethod · 0.95

Calls 2

GitHubActionStepTypeAlias · 0.85

Tested by

no test coverage detected