|
| 1 | +import * as core from "@actions/core"; |
| 2 | + |
| 3 | +export function collectActionInputsPresence(): void { |
| 4 | + const inputDefaults: Record<string, string> = { |
| 5 | + trigger_phrase: "@claude", |
| 6 | + assignee_trigger: "", |
| 7 | + label_trigger: "claude", |
| 8 | + base_branch: "", |
| 9 | + branch_prefix: "claude/", |
| 10 | + allowed_bots: "", |
| 11 | + mode: "tag", |
| 12 | + model: "", |
| 13 | + anthropic_model: "", |
| 14 | + fallback_model: "", |
| 15 | + allowed_tools: "", |
| 16 | + disallowed_tools: "", |
| 17 | + custom_instructions: "", |
| 18 | + direct_prompt: "", |
| 19 | + override_prompt: "", |
| 20 | + mcp_config: "", |
| 21 | + additional_permissions: "", |
| 22 | + claude_env: "", |
| 23 | + settings: "", |
| 24 | + anthropic_api_key: "", |
| 25 | + claude_code_oauth_token: "", |
| 26 | + github_token: "", |
| 27 | + max_turns: "", |
| 28 | + use_sticky_comment: "false", |
| 29 | + use_commit_signing: "false", |
| 30 | + experimental_allowed_domains: "", |
| 31 | + }; |
| 32 | + |
| 33 | + const allInputsJson = process.env.ALL_INPUTS; |
| 34 | + if (!allInputsJson) { |
| 35 | + console.log("ALL_INPUTS environment variable not found"); |
| 36 | + core.setOutput("action_inputs_present", JSON.stringify({})); |
| 37 | + return; |
| 38 | + } |
| 39 | + |
| 40 | + let allInputs: Record<string, string>; |
| 41 | + try { |
| 42 | + allInputs = JSON.parse(allInputsJson); |
| 43 | + } catch (e) { |
| 44 | + console.error("Failed to parse ALL_INPUTS JSON:", e); |
| 45 | + core.setOutput("action_inputs_present", JSON.stringify({})); |
| 46 | + return; |
| 47 | + } |
| 48 | + |
| 49 | + const presentInputs: Record<string, boolean> = {}; |
| 50 | + |
| 51 | + for (const [name, defaultValue] of Object.entries(inputDefaults)) { |
| 52 | + const actualValue = allInputs[name] || ""; |
| 53 | + |
| 54 | + const isSet = actualValue !== defaultValue; |
| 55 | + presentInputs[name] = isSet; |
| 56 | + } |
| 57 | + |
| 58 | + core.setOutput("action_inputs_present", JSON.stringify(presentInputs)); |
| 59 | +} |
0 commit comments