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

Function buildSafeOutputJobEnvVars

pkg/workflow/safe_outputs_env.go:114–133  ·  view source on GitHub ↗

buildSafeOutputJobEnvVars builds environment variables for safe-output jobs with staged/target repo handling This extracts the duplicated env setup logic in safe-output job builders (create_issue, add_comment, etc.)

(trialMode bool, trialLogicalRepoSlug string, staged *TemplatableBool, targetRepoSlug string)

Source from the content-addressed store, hash-verified

112// buildSafeOutputJobEnvVars builds environment variables for safe-output jobs with staged/target repo handling
113// This extracts the duplicated env setup logic in safe-output job builders (create_issue, add_comment, etc.)
114func buildSafeOutputJobEnvVars(trialMode bool, trialLogicalRepoSlug string, staged *TemplatableBool, targetRepoSlug string) []string {
115 var customEnvVars []string
116
117 // Pass the staged flag if it's set to true
118 if value := resolveSafeOutputsStagedValue(trialMode, staged); value != nil {
119 safeOutputsEnvLog.Printf("Setting staged flag: trial_mode=%t, staged=%v", trialMode, staged)
120 customEnvVars = append(customEnvVars, buildTemplatableBoolEnvVar("GH_AW_SAFE_OUTPUTS_STAGED", value)...)
121 }
122
123 // Set GH_AW_TARGET_REPO_SLUG - prefer target-repo config over trial target repo
124 if targetRepoSlug != "" {
125 safeOutputsEnvLog.Printf("Setting target repo slug from config: %s", targetRepoSlug)
126 customEnvVars = append(customEnvVars, fmt.Sprintf(" GH_AW_TARGET_REPO_SLUG: %q\n", targetRepoSlug))
127 } else if trialMode && trialLogicalRepoSlug != "" {
128 safeOutputsEnvLog.Printf("Setting target repo slug from trial mode: %s", trialLogicalRepoSlug)
129 customEnvVars = append(customEnvVars, fmt.Sprintf(" GH_AW_TARGET_REPO_SLUG: %q\n", trialLogicalRepoSlug))
130 }
131
132 return customEnvVars
133}
134
135// buildStandardSafeOutputEnvVars builds the standard set of environment variables
136// that all safe-output job builders need: metadata + staged/target repo handling

Calls 3

PrintfMethod · 0.45

Tested by 1