mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 15:04: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>
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import { $ } from "bun";
|
|
import { homedir } from "os";
|
|
import { readFile } from "fs/promises";
|
|
|
|
export async function setupClaudeCodeSettings(
|
|
settingsInput?: string,
|
|
homeDir?: string,
|
|
) {
|
|
const home = homeDir ?? homedir();
|
|
const settingsPath = `${home}/.claude/settings.json`;
|
|
console.log(`Setting up Claude settings at: ${settingsPath}`);
|
|
|
|
// Ensure .claude directory exists
|
|
console.log(`Creating .claude directory...`);
|
|
await $`mkdir -p ${home}/.claude`.quiet();
|
|
|
|
let settings: Record<string, unknown> = {};
|
|
try {
|
|
const existingSettings = await $`cat ${settingsPath}`.quiet().text();
|
|
if (existingSettings.trim()) {
|
|
settings = JSON.parse(existingSettings);
|
|
console.log(
|
|
`Found existing settings:`,
|
|
JSON.stringify(settings, null, 2),
|
|
);
|
|
} else {
|
|
console.log(`Settings file exists but is empty`);
|
|
}
|
|
} catch (e) {
|
|
console.log(`No existing settings file found, creating new one`);
|
|
}
|
|
|
|
// Handle settings input (either file path or JSON string)
|
|
if (settingsInput && settingsInput.trim()) {
|
|
console.log(`Processing settings input...`);
|
|
let inputSettings: Record<string, unknown> = {};
|
|
|
|
try {
|
|
// First try to parse as JSON
|
|
inputSettings = JSON.parse(settingsInput);
|
|
console.log(`Parsed settings input as JSON`);
|
|
} catch (e) {
|
|
// If not JSON, treat as file path
|
|
console.log(
|
|
`Settings input is not JSON, treating as file path: ${settingsInput}`,
|
|
);
|
|
try {
|
|
const fileContent = await readFile(settingsInput, "utf-8");
|
|
inputSettings = JSON.parse(fileContent);
|
|
console.log(`Successfully read and parsed settings from file`);
|
|
} catch (fileError) {
|
|
console.error(`Failed to read or parse settings file: ${fileError}`);
|
|
throw new Error(`Failed to process settings input: ${fileError}`);
|
|
}
|
|
}
|
|
|
|
// Merge input settings with existing settings
|
|
settings = { ...settings, ...inputSettings };
|
|
console.log(`Merged settings with input settings`);
|
|
}
|
|
|
|
// Always set enableAllProjectMcpServers to true
|
|
settings.enableAllProjectMcpServers = true;
|
|
console.log(`Updated settings with enableAllProjectMcpServers: true`);
|
|
|
|
await $`echo ${JSON.stringify(settings, null, 2)} > ${settingsPath}`.quiet();
|
|
console.log(`Settings saved successfully`);
|
|
}
|