diff --git a/base-action/src/index.ts b/base-action/src/index.ts index 160e64154..80cf2fe65 100644 --- a/base-action/src/index.ts +++ b/base-action/src/index.ts @@ -1,12 +1,21 @@ #!/usr/bin/env bun import * as core from "@actions/core"; +import { $ } from "bun"; import { preparePrompt } from "./prepare-prompt"; import { runClaude } from "./run-claude"; import { setupClaudeCodeSettings } from "./setup-claude-code-settings"; import { validateEnvironmentVariables } from "./validate-env"; import { installPlugins } from "./install-plugins"; +async function configureGitCredentials(token: string): Promise { + // Configure a global git credential helper so that git clone operations + // (e.g. when installing plugin marketplaces from private repos) can + // authenticate using the provided GitHub token. + process.env.GH_TOKEN = token; + await $`git config --global credential.helper '!f() { echo "username=x-access-token"; echo "password=$GH_TOKEN"; }; f'`; +} + async function run() { try { validateEnvironmentVariables(); @@ -24,6 +33,13 @@ async function run() { undefined, // homeDir ); + // Configure git credentials before installing plugins so that private + // marketplace repositories can be cloned successfully. + const githubToken = process.env.GITHUB_TOKEN || process.env.GH_TOKEN; + if (githubToken) { + await configureGitCredentials(githubToken); + } + // Install Claude Code plugins if specified await installPlugins( process.env.INPUT_PLUGIN_MARKETPLACES,