- Create run-claude-core.ts as the central Claude execution function - Update action.yml to use single "Run Claude" step - Create src/entrypoints/run.ts that combines prepare + run-claude logic - Pass environment variables as object to Claude instead of setting process.env - Update create-prompt to return tools (still exports env vars for compatibility) - Add TODO comments for future refactoring to remove env var dependency - Both action.yml and base-action continue to work correctly This simplifies the action flow by removing intermediate steps and environment variable passing between prepare and run-claude phases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
#!/usr/bin/env bun
|
|
|
|
import * as core from "@actions/core";
|
|
import { preparePrompt } from "./prepare-prompt";
|
|
import { runClaudeCore } from "./run-claude-core";
|
|
export { prepareRunConfig, type ClaudeOptions } from "./run-claude-core";
|
|
import { setupClaudeCodeSettings } from "./setup-claude-code-settings";
|
|
import { validateEnvironmentVariables } from "./validate-env";
|
|
|
|
async function run() {
|
|
try {
|
|
validateEnvironmentVariables();
|
|
|
|
await setupClaudeCodeSettings(process.env.INPUT_SETTINGS);
|
|
|
|
const promptConfig = await preparePrompt({
|
|
prompt: process.env.INPUT_PROMPT || "",
|
|
promptFile: process.env.INPUT_PROMPT_FILE || "",
|
|
});
|
|
|
|
await runClaudeCore({
|
|
promptFile: promptConfig.path,
|
|
settings: process.env.INPUT_SETTINGS,
|
|
allowedTools: process.env.INPUT_ALLOWED_TOOLS,
|
|
disallowedTools: process.env.INPUT_DISALLOWED_TOOLS,
|
|
maxTurns: process.env.INPUT_MAX_TURNS,
|
|
mcpConfig: process.env.INPUT_MCP_CONFIG,
|
|
systemPrompt: process.env.INPUT_SYSTEM_PROMPT,
|
|
appendSystemPrompt: process.env.INPUT_APPEND_SYSTEM_PROMPT,
|
|
claudeEnv: process.env.INPUT_CLAUDE_ENV,
|
|
fallbackModel: process.env.INPUT_FALLBACK_MODEL,
|
|
model: process.env.ANTHROPIC_MODEL,
|
|
timeoutMinutes: process.env.INPUT_TIMEOUT_MINUTES,
|
|
});
|
|
} catch (error) {
|
|
core.setFailed(`Action failed with error: ${error}`);
|
|
core.setOutput("conclusion", "failure");
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
run();
|
|
}
|