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

Method addCustomActionGitHubToken

pkg/workflow/safe_outputs_steps.go:72–100  ·  view source on GitHub ↗

addCustomActionGitHubToken adds a GitHub token as action input. The token precedence depends on the tokenType flags: - UseCopilotCodingAgentToken: customToken > SafeOutputs.GitHubToken > GH_AW_AGENT_TOKEN || GH_AW_GITHUB_TOKEN || GITHUB_TOKEN - UseCopilotRequestsToken: customToken > SafeOutputs.GitH

(steps *[]string, data *WorkflowData, config GitHubScriptStepConfig)

Source from the content-addressed store, hash-verified

70// - UseCopilotRequestsToken: customToken > SafeOutputs.GitHubToken > COPILOT_GITHUB_TOKEN
71// - Default: customToken > SafeOutputs.GitHubToken > GH_AW_GITHUB_TOKEN || GITHUB_TOKEN
72func (c *Compiler) addCustomActionGitHubToken(steps *[]string, data *WorkflowData, config GitHubScriptStepConfig) {
73 safeOutputsStepsLog.Printf("Selecting GitHub token for step: %s (copilotCodingAgent=%t, copilotRequests=%t)", config.StepName, config.UseCopilotCodingAgentToken, config.UseCopilotRequestsToken)
74 var token string
75
76 // Get safe-outputs level token
77 var safeOutputsToken string
78 if data.SafeOutputs != nil {
79 safeOutputsToken = data.SafeOutputs.GitHubToken
80 }
81
82 // Choose the first non-empty custom token for precedence
83 effectiveCustomToken := config.CustomToken
84 if effectiveCustomToken == "" {
85 effectiveCustomToken = safeOutputsToken
86 }
87
88 // Agent token mode: use full precedence chain for agent assignment
89 if config.UseCopilotCodingAgentToken {
90 token = getEffectiveCopilotCodingAgentGitHubToken(effectiveCustomToken)
91 } else if config.UseCopilotRequestsToken {
92 // Copilot mode: use getEffectiveCopilotRequestsToken with safe-outputs token precedence
93 token = getEffectiveCopilotRequestsToken(effectiveCustomToken)
94 } else {
95 // Standard mode: use safe output token chain
96 token = getEffectiveSafeOutputGitHubToken(effectiveCustomToken)
97 }
98
99 *steps = append(*steps, fmt.Sprintf(" token: %s\n", token))
100}
101
102// GitHubScriptStepConfig holds configuration for building a GitHub Script step
103type GitHubScriptStepConfig struct {

Callers 1

buildCustomActionStepMethod · 0.95

Tested by

no test coverage detected