diff --git a/src/github/api/config.ts b/src/github/api/config.ts index 7d88fb8..62bc614 100644 --- a/src/github/api/config.ts +++ b/src/github/api/config.ts @@ -2,5 +2,4 @@ export const GITHUB_API_URL = process.env.GITHUB_API_URL || "https://api.github.com"; export const GITHUB_SERVER_URL = process.env.GITHUB_SERVER_URL || "https://github.com"; -export const USE_GITEA_API = process.env.USE_GITEA_API === "true" || process.env.USE_GITEA_API === "1"; -export const GITEA_BOT_USERNAMES = (process.env.GITEA_BOT_USERNAMES || "").split(",") \ No newline at end of file +export const USE_GITEA_API = process.env.USE_GITEA_API === "true" || process.env.USE_GITEA_API === "1"; \ No newline at end of file diff --git a/src/github/validation/actor.ts b/src/github/validation/actor.ts index 23ee999..18e83b3 100644 --- a/src/github/validation/actor.ts +++ b/src/github/validation/actor.ts @@ -7,31 +7,26 @@ import type { Octokit } from "@octokit/rest"; import type { GitHubContext } from "../context"; -import { GITEA_BOT_USERNAMES, USE_GITEA_API } from "../api/config.ts"; +import { USE_GITEA_API } from "../api/config.ts"; export async function checkHumanActor( octokit: Octokit, githubContext: GitHubContext, ) { - + let actorType: string if (USE_GITEA_API) { - if (!GITEA_BOT_USERNAMES.includes(githubContext.actor)) { - throw new Error( - `Workflow initiated by non-human actor: ${githubContext.actor}. Please add bot to GITEA_BOT_USERNAMES`, - ); - } - // For Gitea environments, skip the user type check if USE_GITEA_API is set - return; + actorType = "Bot" + console.log("Gitea does not provide an API to determine whether a user is a bot. Assuming the user is a bot and verify whether it is listed in allowedBots.") + }else{ + // Fetch user information from GitHub API + const { data: userData } = await octokit.users.getByUsername({ + username: githubContext.actor, + }); + + actorType = userData.type; } - // 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}`); // Check bot permissions if actor is not a User