Skip to content

Commit 68b7ca3

Browse files
authored
include input bools in claude env (#464)
1 parent 900322c commit 68b7ca3

4 files changed

Lines changed: 73 additions & 3 deletions

File tree

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ runs:
166166
DEFAULT_WORKFLOW_TOKEN: ${{ github.token }}
167167
ADDITIONAL_PERMISSIONS: ${{ inputs.additional_permissions }}
168168
USE_COMMIT_SIGNING: ${{ inputs.use_commit_signing }}
169+
ALL_INPUTS: ${{ toJson(inputs) }}
169170

170171
- name: Install Base Action Dependencies
171172
if: steps.prepare.outputs.contains_trigger == 'true'
@@ -212,6 +213,7 @@ runs:
212213
INPUT_CLAUDE_ENV: ${{ inputs.claude_env }}
213214
INPUT_FALLBACK_MODEL: ${{ inputs.fallback_model }}
214215
INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ github.action_path }}/slash-commands
216+
INPUT_ACTION_INPUTS_PRESENT: ${{ steps.prepare.outputs.action_inputs_present }}
215217

216218
# Model configuration
217219
ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}

base-action/src/run-claude.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ export function prepareRunConfig(
110110
// Parse custom environment variables
111111
const customEnv = parseCustomEnvVars(options.claudeEnv);
112112

113+
if (process.env.INPUT_ACTION_INPUTS_PRESENT) {
114+
customEnv.GITHUB_ACTION_INPUTS = process.env.INPUT_ACTION_INPUTS_PRESENT;
115+
}
116+
113117
return {
114118
claudeArgs,
115119
promptPath,
@@ -142,9 +146,11 @@ export async function runClaude(promptPath: string, options: ClaudeOptions) {
142146
console.log(`Prompt file size: ${promptSize} bytes`);
143147

144148
// Log custom environment variables if any
145-
if (Object.keys(config.env).length > 0) {
146-
const envKeys = Object.keys(config.env).join(", ");
147-
console.log(`Custom environment variables: ${envKeys}`);
149+
const customEnvKeys = Object.keys(config.env).filter(
150+
(key) => key !== "CLAUDE_ACTION_INPUTS_PRESENT",
151+
);
152+
if (customEnvKeys.length > 0) {
153+
console.log(`Custom environment variables: ${customEnvKeys.join(", ")}`);
148154
}
149155

150156
// Output to console

src/entrypoints/collect-inputs.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
}

src/entrypoints/prepare.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ import { parseGitHubContext, isEntityContext } from "../github/context";
1313
import { getMode, isValidMode, DEFAULT_MODE } from "../modes/registry";
1414
import type { ModeName } from "../modes/types";
1515
import { prepare } from "../prepare";
16+
import { collectActionInputsPresence } from "./collect-inputs";
1617

1718
async function run() {
1819
try {
20+
collectActionInputsPresence();
21+
1922
// Step 1: Get mode first to determine authentication method
2023
const modeInput = process.env.MODE || DEFAULT_MODE;
2124

0 commit comments

Comments
 (0)