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

Function applySafeOutputEnvToMap

pkg/workflow/safe_outputs_env.go:46–74  ·  view source on GitHub ↗

======================================== Safe Output Environment Variables ======================================== applySafeOutputEnvToMap adds safe-output related environment variables to an env map This extracts the duplicated safe-output env setup logic across all engines (copilot, codex, claude

(env map[string]string, data *WorkflowData)

Source from the content-addressed store, hash-verified

44// applySafeOutputEnvToMap adds safe-output related environment variables to an env map
45// This extracts the duplicated safe-output env setup logic across all engines (copilot, codex, claude, custom)
46func applySafeOutputEnvToMap(env map[string]string, data *WorkflowData) {
47 if data.SafeOutputs == nil {
48 return
49 }
50
51 safeOutputsEnvLog.Printf("Applying safe output env vars: trial_mode=%t, staged=%v", data.TrialMode, data.SafeOutputs.Staged)
52
53 env["GH_AW_SAFE_OUTPUTS"] = "${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}"
54
55 // Add staged flag if specified
56 if value := resolveSafeOutputsStagedValue(data.TrialMode, data.SafeOutputs.Staged); value != nil {
57 if isExpression(*value) {
58 env["GH_AW_SAFE_OUTPUTS_STAGED"] = *value
59 } else {
60 env["GH_AW_SAFE_OUTPUTS_STAGED"] = "true"
61 }
62 }
63 if data.TrialMode && data.TrialLogicalRepo != "" {
64 env["GH_AW_TARGET_REPO_SLUG"] = data.TrialLogicalRepo
65 }
66
67 // Add branch name if upload assets is configured
68 if data.SafeOutputs.UploadAssets != nil {
69 safeOutputsEnvLog.Printf("Adding upload assets env vars: branch=%s", data.SafeOutputs.UploadAssets.BranchName)
70 env["GH_AW_ASSETS_BRANCH"] = fmt.Sprintf("%q", data.SafeOutputs.UploadAssets.BranchName)
71 env["GH_AW_ASSETS_MAX_SIZE_KB"] = strconv.Itoa(data.SafeOutputs.UploadAssets.MaxSizeKB)
72 env["GH_AW_ASSETS_ALLOWED_EXTS"] = fmt.Sprintf("%q", strings.Join(data.SafeOutputs.UploadAssets.AllowedExts, ","))
73 }
74}
75
76// buildWorkflowMetadataEnvVars builds workflow name and source environment variables
77// This extracts the duplicated workflow metadata setup logic from safe-output job builders

Callers 9

GetExecutionStepsMethod · 0.85
GetExecutionStepsMethod · 0.85
GetExecutionStepsMethod · 0.85
GetExecutionStepsMethod · 0.85
GetExecutionStepsMethod · 0.85

Calls 3

isExpressionFunction · 0.85
PrintfMethod · 0.45

Tested by 2