github token
This commit is contained in:
+1
-3
@@ -1,3 +1 @@
|
|||||||
Print the MCP tools available to you.
|
write a comment to https://github.com/pullfrogai/scratch/pull/29 that tells a joke
|
||||||
Try to call select_mode with the name "Plan".
|
|
||||||
Then tell me a joke
|
|
||||||
@@ -135,7 +135,6 @@ To fix this, add the required secret to your GitHub repository:
|
|||||||
interface MainContext {
|
interface MainContext {
|
||||||
inputs: Inputs;
|
inputs: Inputs;
|
||||||
githubInstallationToken: string;
|
githubInstallationToken: string;
|
||||||
tokenToRevoke: string | null;
|
|
||||||
repoContext: RepoContext;
|
repoContext: RepoContext;
|
||||||
agentName: AgentNameType;
|
agentName: AgentNameType;
|
||||||
agent: (typeof agents)[AgentNameType];
|
agent: (typeof agents)[AgentNameType];
|
||||||
@@ -155,16 +154,14 @@ async function initializeContext(
|
|||||||
Inputs.assert(inputs);
|
Inputs.assert(inputs);
|
||||||
setupGitConfig();
|
setupGitConfig();
|
||||||
|
|
||||||
const { githubInstallationToken, wasAcquired } = await setupGitHubInstallationToken();
|
const githubInstallationToken = await setupGitHubInstallationToken();
|
||||||
const tokenToRevoke = wasAcquired ? githubInstallationToken : null;
|
|
||||||
const repoContext = parseRepoContext();
|
const repoContext = parseRepoContext();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
inputs,
|
inputs,
|
||||||
githubInstallationToken,
|
githubInstallationToken,
|
||||||
tokenToRevoke,
|
|
||||||
repoContext,
|
repoContext,
|
||||||
agentName: "claude" as AgentNameType,
|
agentName: "claude",
|
||||||
agent: agents.claude,
|
agent: agents.claude,
|
||||||
sharedTempDir: "",
|
sharedTempDir: "",
|
||||||
mcpLogPath: "",
|
mcpLogPath: "",
|
||||||
@@ -292,7 +289,5 @@ async function cleanup(ctx: Omit<MainContext, "mcpServers" | "cliPath" | "apiKey
|
|||||||
if (ctx.pollInterval) {
|
if (ctx.pollInterval) {
|
||||||
clearInterval(ctx.pollInterval);
|
clearInterval(ctx.pollInterval);
|
||||||
}
|
}
|
||||||
if (ctx.tokenToRevoke) {
|
await revokeInstallationToken(ctx.githubInstallationToken);
|
||||||
await revokeInstallationToken(ctx.tokenToRevoke);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export async function run(prompt: string): Promise<AgentResult> {
|
|||||||
// we don't need to extract it here since main() will parse the payload
|
// we don't need to extract it here since main() will parse the payload
|
||||||
const inputs: Required<Inputs> = {
|
const inputs: Required<Inputs> = {
|
||||||
prompt,
|
prompt,
|
||||||
defaultAgent: "cursor",
|
defaultAgent: "gemini",
|
||||||
...flatMorph(agents, (_, agent) =>
|
...flatMorph(agents, (_, agent) =>
|
||||||
agent.apiKeyNames.map((inputKey) => [inputKey, process.env[inputKey.toUpperCase()]])
|
agent.apiKeyNames.map((inputKey) => [inputKey, process.env[inputKey.toUpperCase()]])
|
||||||
),
|
),
|
||||||
|
|||||||
+2
-19
@@ -43,12 +43,6 @@ interface RepositoriesResponse {
|
|||||||
repositories: Repository[];
|
repositories: Repository[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExistingToken(): string | null {
|
|
||||||
const inputToken = core.getInput("github_installation_token");
|
|
||||||
const envToken = process.env.GITHUB_INSTALLATION_TOKEN;
|
|
||||||
return inputToken || envToken || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isGitHubActionsEnvironment(): boolean {
|
function isGitHubActionsEnvironment(): boolean {
|
||||||
return Boolean(process.env.GITHUB_ACTIONS);
|
return Boolean(process.env.GITHUB_ACTIONS);
|
||||||
}
|
}
|
||||||
@@ -249,24 +243,13 @@ async function acquireNewToken(): Promise<string> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup GitHub installation token for the action
|
* Setup GitHub installation token for the action
|
||||||
* Returns the token and whether it was acquired (needs revocation)
|
|
||||||
*/
|
*/
|
||||||
export async function setupGitHubInstallationToken(): Promise<{
|
export async function setupGitHubInstallationToken(): Promise<string> {
|
||||||
githubInstallationToken: string;
|
|
||||||
wasAcquired: boolean;
|
|
||||||
}> {
|
|
||||||
const existingToken = checkExistingToken();
|
|
||||||
if (existingToken) {
|
|
||||||
core.setSecret(existingToken);
|
|
||||||
log.info("Using provided GitHub installation token");
|
|
||||||
return { githubInstallationToken: existingToken, wasAcquired: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
const acquiredToken = await acquireNewToken();
|
const acquiredToken = await acquireNewToken();
|
||||||
core.setSecret(acquiredToken);
|
core.setSecret(acquiredToken);
|
||||||
process.env.GITHUB_INSTALLATION_TOKEN = acquiredToken;
|
process.env.GITHUB_INSTALLATION_TOKEN = acquiredToken;
|
||||||
|
|
||||||
return { githubInstallationToken: acquiredToken, wasAcquired: true };
|
return acquiredToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user