mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 15:04:13 +08:00
32 lines
796 B
TypeScript
32 lines
796 B
TypeScript
#!/usr/bin/env bun
|
|
|
|
/**
|
|
* Check if the action trigger is from a human actor
|
|
* Prevents automated tools or bots from triggering Claude
|
|
*/
|
|
|
|
import type { Octokit } from "@octokit/rest";
|
|
import type { ParsedGitHubContext } from "../context";
|
|
|
|
export async function checkHumanActor(
|
|
octokit: Octokit,
|
|
githubContext: ParsedGitHubContext,
|
|
) {
|
|
// Fetch user information from GitHub API
|
|
const { data: userData } = await octokit.users.getByUsername({
|
|
username: githubContext.actor,
|
|
});
|
|
|
|
const actorType = userData.type;
|
|
|
|
console.log(`Actor type: ${actorType}`);
|
|
|
|
if (actorType !== "User") {
|
|
throw new Error(
|
|
`Workflow initiated by non-human actor: ${githubContext.actor} (type: ${actorType}).`,
|
|
);
|
|
}
|
|
|
|
console.log(`Verified human actor: ${githubContext.actor}`);
|
|
}
|