mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
fix: move critical outputs to immediately after prepare step
Previously, outputs like GITHUB_TOKEN and branch_name were set after Claude execution completed. This caused issues if Claude failed, as downstream cleanup steps wouldn't have access to these outputs. Now outputs are set immediately after prepare() completes, ensuring they're available even if Claude execution fails.
This commit is contained in:
@@ -80,6 +80,19 @@ async function run() {
|
|||||||
githubToken,
|
githubToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set critical outputs immediately after prepare completes
|
||||||
|
// This ensures they're available for cleanup even if Claude fails
|
||||||
|
core.setOutput("GITHUB_TOKEN", githubToken);
|
||||||
|
core.setOutput("mcp_config", prepareResult.mcpConfig);
|
||||||
|
if (prepareResult.branchInfo.claudeBranch) {
|
||||||
|
core.setOutput("branch_name", prepareResult.branchInfo.claudeBranch);
|
||||||
|
core.setOutput("CLAUDE_BRANCH", prepareResult.branchInfo.claudeBranch);
|
||||||
|
}
|
||||||
|
core.setOutput("BASE_BRANCH", prepareResult.branchInfo.baseBranch);
|
||||||
|
if (prepareResult.commentId) {
|
||||||
|
core.setOutput("claude_comment_id", prepareResult.commentId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
// Step 7: The mode.prepare() call already created the prompt and set up tools
|
// Step 7: The mode.prepare() call already created the prompt and set up tools
|
||||||
// We need to get the allowed/disallowed tools from environment variables
|
// We need to get the allowed/disallowed tools from environment variables
|
||||||
// TODO: Update Mode interface to return tools from prepare() instead of relying on env vars
|
// TODO: Update Mode interface to return tools from prepare() instead of relying on env vars
|
||||||
@@ -102,8 +115,6 @@ async function run() {
|
|||||||
CLAUDE_CODE_ACTION: "1",
|
CLAUDE_CODE_ACTION: "1",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Run Claude using the shared core function
|
|
||||||
try {
|
|
||||||
await runClaudeCore({
|
await runClaudeCore({
|
||||||
promptFile,
|
promptFile,
|
||||||
settings: process.env.SETTINGS,
|
settings: process.env.SETTINGS,
|
||||||
@@ -119,23 +130,6 @@ async function run() {
|
|||||||
timeoutMinutes: process.env.TIMEOUT_MINUTES || "30",
|
timeoutMinutes: process.env.TIMEOUT_MINUTES || "30",
|
||||||
env: claudeEnvObject,
|
env: claudeEnvObject,
|
||||||
});
|
});
|
||||||
} catch (claudeError) {
|
|
||||||
// The outputs should already be set by runClaudeCore
|
|
||||||
// Just re-throw to handle in outer catch
|
|
||||||
throw claudeError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set outputs that were previously set by prepare step
|
|
||||||
core.setOutput("GITHUB_TOKEN", githubToken);
|
|
||||||
core.setOutput("mcp_config", prepareResult.mcpConfig);
|
|
||||||
if (prepareResult.branchInfo.claudeBranch) {
|
|
||||||
core.setOutput("branch_name", prepareResult.branchInfo.claudeBranch);
|
|
||||||
core.setOutput("CLAUDE_BRANCH", prepareResult.branchInfo.claudeBranch);
|
|
||||||
}
|
|
||||||
core.setOutput("BASE_BRANCH", prepareResult.branchInfo.baseBranch);
|
|
||||||
if (prepareResult.commentId) {
|
|
||||||
core.setOutput("claude_comment_id", prepareResult.commentId.toString());
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
core.setFailed(`Action failed with error: ${errorMessage}`);
|
core.setFailed(`Action failed with error: ${errorMessage}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user