fix installation token propagation
This commit is contained in:
@@ -10,9 +10,6 @@ inputs:
|
||||
anthropic_api_key:
|
||||
description: "Anthropic API key for Claude Code authentication"
|
||||
required: false
|
||||
github_installation_token:
|
||||
description: "GitHub App installation token"
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
||||
+4
-2
@@ -10,6 +10,7 @@ import type { Agent, AgentConfig, AgentResult } from "./types.ts";
|
||||
*/
|
||||
export class ClaudeAgent implements Agent {
|
||||
private apiKey: string;
|
||||
private githubInstallationToken?: string;
|
||||
public runStats = {
|
||||
toolsUsed: 0,
|
||||
turns: 0,
|
||||
@@ -21,6 +22,7 @@ export class ClaudeAgent implements Agent {
|
||||
throw new Error("Claude agent requires an API key");
|
||||
}
|
||||
this.apiKey = config.apiKey;
|
||||
this.githubInstallationToken = config.githubInstallationToken;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,13 +92,13 @@ export class ClaudeAgent implements Agent {
|
||||
"bypassPermissions",
|
||||
];
|
||||
|
||||
if (!process.env.GITHUB_INSTALLATION_TOKEN) {
|
||||
if (!this.githubInstallationToken) {
|
||||
throw new Error(
|
||||
"GITHUB_INSTALLATION_TOKEN is required for GitHub integration"
|
||||
);
|
||||
}
|
||||
|
||||
const mcpConfig = createMcpConfig(process.env.GITHUB_INSTALLATION_TOKEN);
|
||||
const mcpConfig = createMcpConfig(this.githubInstallationToken);
|
||||
console.log("📋 MCP Config:", mcpConfig);
|
||||
args.push("--mcp-config", mcpConfig);
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import * as core from "@actions/core";
|
||||
import { type } from "arktype";
|
||||
import { ClaudeAgent } from "./agents/claude.ts";
|
||||
import { setupGitHubInstallationToken } from "./utils/github.ts";
|
||||
|
||||
export const Inputs = type({
|
||||
prompt: "string",
|
||||
"anthropic_api_key?": "string | undefined",
|
||||
"github_installation_token?": "string | undefined",
|
||||
});
|
||||
|
||||
export type ActionInputs = typeof Inputs.infer;
|
||||
@@ -20,7 +20,13 @@ export async function main(inputs: ActionInputs): Promise<MainResult> {
|
||||
try {
|
||||
core.info(`→ Starting agent run with Claude Code`);
|
||||
|
||||
const agent = new ClaudeAgent({ apiKey: inputs.anthropic_api_key! });
|
||||
// Setup GitHub installation token
|
||||
const githubInstallationToken = await setupGitHubInstallationToken();
|
||||
|
||||
const agent = new ClaudeAgent({
|
||||
apiKey: inputs.anthropic_api_key!,
|
||||
githubInstallationToken
|
||||
});
|
||||
await agent.install();
|
||||
|
||||
const result = await agent.execute(inputs.prompt);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pullfrog/action",
|
||||
"version": "0.0.45",
|
||||
"version": "0.0.46",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"index.js",
|
||||
|
||||
@@ -7,7 +7,6 @@ import { config } from "dotenv";
|
||||
import { type ActionInputs, main } from "./main.ts";
|
||||
import packageJson from "./package.json" with { type: "json" };
|
||||
import { runAct } from "./utils/act.ts";
|
||||
import { setupGitHubInstallationToken } from "./utils/github.ts";
|
||||
import { setupTestRepo } from "./utils/setup.ts";
|
||||
|
||||
config();
|
||||
@@ -36,16 +35,9 @@ export async function run(
|
||||
console.log(prompt);
|
||||
console.log("─".repeat(50));
|
||||
|
||||
console.log("🔑 Setting up GitHub installation token...");
|
||||
const installationToken = await setupGitHubInstallationToken();
|
||||
process.env.GITHUB_INSTALLATION_TOKEN = installationToken;
|
||||
|
||||
console.log("✅ GitHub installation token setup successfully");
|
||||
|
||||
const inputs: ActionInputs = {
|
||||
prompt,
|
||||
anthropic_api_key: process.env.ANTHROPIC_API_KEY,
|
||||
github_installation_token: installationToken,
|
||||
};
|
||||
|
||||
const result = await main(inputs);
|
||||
|
||||
Reference in New Issue
Block a user