-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathconfig.ts
More file actions
127 lines (113 loc) · 3.81 KB
/
config.ts
File metadata and controls
127 lines (113 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import * as core from '@actions/core';
import * as github from '@actions/github';
import { Octokit } from 'octokit';
export interface ActionConfig {
// Required
githubToken: string;
anthropicApiKey: string;
eventPath: string;
timeoutSeconds: number;
// Optional
anthropicBaseUrl: string;
anthropicModel: string;
anthropicSmallFastModel: string;
// Optional: Use Bedrock
claudeCodeUseBedrock: string;
anthropicBedrockBaseUrl: string;
awsAccessKeyId: string;
awsSecretAccessKey: string;
awsRegion: string;
disablePromptCaching: string;
// Optional: Use Claude Code Proxy
useClaudeCodeProxy: string;
claudeCodeProxyCwd: string;
claudeCodePort: number;
proxyOpenaiApiKey: string;
proxyGeminiApiKey: string;
proxyPreferredProvider: string;
proxyBigModel: string;
proxySmallModel: string;
// Context and repo information
workspace: string;
octokit: Octokit;
context: typeof github.context;
repo: { owner: string; repo: string };
}
/**
* Gets and validates the inputs for the GitHub Action.
* @returns ActionConfig object
* @throws Error if required inputs are missing
*/
export function getConfig(): ActionConfig {
// Required
const githubToken = core.getInput('github-token', { required: true });
let anthropicApiKey = core.getInput('anthropic-api-key');
const eventPath = core.getInput('event-path', { required: true });
const timeoutSeconds = core.getInput('timeout') ? parseInt(core.getInput('timeout'), 10) : 300;
// Optional
let anthropicBaseUrl = core.getInput('anthropic-base-url') || '';
const anthropicModel = core.getInput('anthropic-model') || '';
const anthropicSmallFastModel = core.getInput('anthropic-small-fast-model') || '';
// Optional: Use Bedrock
const claudeCodeUseBedrock = core.getInput('claude-code-use-bedrock') || '';
const anthropicBedrockBaseUrl = core.getInput('anthropic-bedrock-base-url') || '';
const awsAccessKeyId = core.getInput('aws-access-key-id') || '';
const awsSecretAccessKey = core.getInput('aws-secret-access-key') || '';
const awsRegion = core.getInput('aws-region') || '';
const disablePromptCaching = core.getInput('disable-prompt-caching') || '';
// Optional: Use Claude Code Proxy
const useClaudeCodeProxy = core.getInput('use-claude-code-proxy') || '';
const claudeCodeProxyCwd = '/claude-code-proxy';
const claudeCodePort = 8082;
const proxyOpenaiApiKey = core.getInput('proxy-openai-api-key') || '';
const proxyGeminiApiKey = core.getInput('proxy-gemini-api-key') || '';
const proxyPreferredProvider = core.getInput('proxy-preferred-provider') || '';
const proxyBigModel = core.getInput('proxy-big-model') || '';
const proxySmallModel = core.getInput('proxy-small-model') || '';
if (!anthropicApiKey && !useClaudeCodeProxy) {
throw new Error('Anthropic API Key is required.');
}
if (!githubToken) {
throw new Error('GitHub Token is required.');
}
if (!eventPath) {
throw new Error('GitHub event path is missing.');
}
// use proxy overwrites base url
if (useClaudeCodeProxy) {
anthropicApiKey = 'dummy';
anthropicBaseUrl = 'http://localhost:' + claudeCodePort;
}
// Context and repo information
const workspace = '/workspace/app';
const octokit = new Octokit({ auth: githubToken });
const context = github.context;
const repo = context.repo;
return {
githubToken,
anthropicApiKey,
eventPath,
timeoutSeconds,
anthropicBaseUrl,
anthropicModel,
anthropicSmallFastModel,
claudeCodeUseBedrock,
anthropicBedrockBaseUrl,
awsAccessKeyId,
awsSecretAccessKey,
awsRegion,
disablePromptCaching,
useClaudeCodeProxy,
claudeCodeProxyCwd,
claudeCodePort,
proxyOpenaiApiKey,
proxyGeminiApiKey,
proxyPreferredProvider,
proxyBigModel,
proxySmallModel,
workspace,
octokit,
context,
repo
};
}