mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
* feat: integrate claude-code-base-action as local subaction
- Copy claude-code-base-action into base-action/ directory
- Update action.yml to reference ./base-action instead of external repo
- Preserve complete base action structure for future refactoring
This eliminates the external dependency while maintaining modularity.
* feat: consolidate CI workflows and add version bump workflow
- Move base-action test workflows to main .github/workflows/
- Update workflow references to use ./base-action
- Add CI jobs for base-action (test, typecheck, prettier)
- Add bump-claude-code-version workflow for base-action
- Remove redundant .github directory from base-action
This consolidates all CI workflows in one place while maintaining
full test coverage for both the main action and base-action.
* tsc
* copy again
* fix tests
* fix: use absolute path for base-action reference
Replace relative path ./base-action with ${{ github.action_path }}/base-action
to ensure the action works correctly when used in other repositories.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: inline base-action execution to support usage in other repos
Replace uses: ./base-action with direct shell execution since GitHub Actions
doesn't support dynamic paths in composite actions. This ensures the action
works correctly when used in other repositories.
Changes:
- Install Claude Code globally before execution
- Run base-action's index.ts directly with bun
- Pass all required INPUT_* environment variables
- Maintain base-action for future separate publishing
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
import { existsSync, statSync } from "fs";
|
|
import { mkdir, writeFile } from "fs/promises";
|
|
|
|
export type PreparePromptInput = {
|
|
prompt: string;
|
|
promptFile: string;
|
|
};
|
|
|
|
export type PreparePromptConfig = {
|
|
type: "file" | "inline";
|
|
path: string;
|
|
};
|
|
|
|
async function validateAndPreparePrompt(
|
|
input: PreparePromptInput,
|
|
): Promise<PreparePromptConfig> {
|
|
// Validate inputs
|
|
if (!input.prompt && !input.promptFile) {
|
|
throw new Error(
|
|
"Neither 'prompt' nor 'prompt_file' was provided. At least one is required.",
|
|
);
|
|
}
|
|
|
|
if (input.prompt && input.promptFile) {
|
|
throw new Error(
|
|
"Both 'prompt' and 'prompt_file' were provided. Please specify only one.",
|
|
);
|
|
}
|
|
|
|
// Handle prompt file
|
|
if (input.promptFile) {
|
|
if (!existsSync(input.promptFile)) {
|
|
throw new Error(`Prompt file '${input.promptFile}' does not exist.`);
|
|
}
|
|
|
|
// Validate that the file is not empty
|
|
const stats = statSync(input.promptFile);
|
|
if (stats.size === 0) {
|
|
throw new Error(
|
|
"Prompt file is empty. Please provide a non-empty prompt.",
|
|
);
|
|
}
|
|
|
|
return {
|
|
type: "file",
|
|
path: input.promptFile,
|
|
};
|
|
}
|
|
|
|
// Handle inline prompt
|
|
if (!input.prompt || input.prompt.trim().length === 0) {
|
|
throw new Error("Prompt is empty. Please provide a non-empty prompt.");
|
|
}
|
|
|
|
const inlinePath = "/tmp/claude-action/prompt.txt";
|
|
return {
|
|
type: "inline",
|
|
path: inlinePath,
|
|
};
|
|
}
|
|
|
|
async function createTemporaryPromptFile(
|
|
prompt: string,
|
|
promptPath: string,
|
|
): Promise<void> {
|
|
// Create the directory path
|
|
const dirPath = promptPath.substring(0, promptPath.lastIndexOf("/"));
|
|
await mkdir(dirPath, { recursive: true });
|
|
await writeFile(promptPath, prompt);
|
|
}
|
|
|
|
export async function preparePrompt(
|
|
input: PreparePromptInput,
|
|
): Promise<PreparePromptConfig> {
|
|
const config = await validateAndPreparePrompt(input);
|
|
|
|
if (config.type === "inline") {
|
|
await createTemporaryPromptFile(input.prompt, config.path);
|
|
}
|
|
|
|
return config;
|
|
}
|