generateCrushConfigStep writes .crush.json with all permissions set to allow to prevent CI hanging on permission prompts.
(_ *WorkflowData)
| 156 | // generateCrushConfigStep writes .crush.json with all permissions set to allow |
| 157 | // to prevent CI hanging on permission prompts. |
| 158 | func (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 |
| 166 | mkdir -p "$GITHUB_WORKSPACE" |
| 167 | CONFIG="$GITHUB_WORKSPACE/.crush.json" |
| 168 | BASE_CONFIG='%s' |
| 169 | if [ -f "$CONFIG" ]; then |
| 170 | MERGED=$(jq -n --argjson base "$BASE_CONFIG" --argjson existing "$(cat "$CONFIG")" '$existing * $base') |
| 171 | echo "$MERGED" > "$CONFIG" |
| 172 | else |
| 173 | echo "$BASE_CONFIG" > "$CONFIG" |
| 174 | fi |
| 175 | chmod 600 "$CONFIG"`, configJSON) |
| 176 | |
| 177 | stepLines := []string{" - name: Write Crush Config"} |
| 178 | stepLines = FormatStepWithCommandAndEnv(stepLines, command, nil) |
| 179 | return GitHubActionStep(stepLines) |
| 180 | } |
no test coverage detected