======================================== Safe Output Step Builders ======================================== buildCustomActionStep creates a step that uses a custom action reference instead of inline JavaScript via actions/github-script
(data *WorkflowData, config GitHubScriptStepConfig, scriptName string)
| 16 | // buildCustomActionStep creates a step that uses a custom action reference |
| 17 | // instead of inline JavaScript via actions/github-script |
| 18 | func (c *Compiler) buildCustomActionStep(data *WorkflowData, config GitHubScriptStepConfig, scriptName string) []string { |
| 19 | safeOutputsStepsLog.Printf("Building custom action step: %s (scriptName=%s, actionMode=%s)", config.StepName, scriptName, c.actionMode) |
| 20 | |
| 21 | var steps []string |
| 22 | |
| 23 | // Get the action path from the script registry |
| 24 | actionPath := DefaultScriptRegistry.GetActionPath(scriptName) |
| 25 | if actionPath == "" { |
| 26 | safeOutputsStepsLog.Printf("WARNING: No action path found for script %s, falling back to inline mode", scriptName) |
| 27 | // Set ScriptFile for inline mode fallback |
| 28 | config.ScriptFile = scriptName + ".cjs" |
| 29 | return c.buildGitHubScriptStep(data, config) |
| 30 | } |
| 31 | |
| 32 | // Resolve the action reference based on mode |
| 33 | actionRef := c.resolveActionReference(actionPath, data) |
| 34 | if actionRef == "" { |
| 35 | safeOutputsStepsLog.Printf("WARNING: Could not resolve action reference for %s, falling back to inline mode", actionPath) |
| 36 | // Set ScriptFile for inline mode fallback |
| 37 | config.ScriptFile = scriptName + ".cjs" |
| 38 | return c.buildGitHubScriptStep(data, config) |
| 39 | } |
| 40 | |
| 41 | // Add artifact download steps before the custom action step. |
| 42 | // In workflow_call context, use the per-invocation prefix to avoid artifact name clashes. |
| 43 | // These steps are used in jobs that depend on the agent job (not activation), so use |
| 44 | // the agent-downstream prefix expression. |
| 45 | steps = append(steps, buildAgentOutputDownloadSteps(artifactPrefixExprForAgentDownstreamJob(data), c.getActionPin)...) |
| 46 | |
| 47 | // Step name and metadata |
| 48 | steps = append(steps, fmt.Sprintf(" - name: %s\n", config.StepName)) |
| 49 | steps = append(steps, fmt.Sprintf(" id: %s\n", config.StepID)) |
| 50 | steps = append(steps, fmt.Sprintf(" uses: %s\n", actionRef)) |
| 51 | |
| 52 | // Environment variables section |
| 53 | steps = append(steps, " env:\n") |
| 54 | steps = append(steps, " GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}\n") |
| 55 | steps = append(steps, config.CustomEnvVars...) |
| 56 | c.addCustomSafeOutputEnvVars(&steps, data) |
| 57 | |
| 58 | // With section for inputs (replaces github-token in actions/github-script) |
| 59 | steps = append(steps, " with:\n") |
| 60 | |
| 61 | // Map github-token to token input for custom actions |
| 62 | c.addCustomActionGitHubToken(&steps, data, config) |
| 63 | |
| 64 | return steps |
| 65 | } |
| 66 | |
| 67 | // addCustomActionGitHubToken adds a GitHub token as action input. |
| 68 | // The token precedence depends on the tokenType flags: |
no test coverage detected