Attempt to make this work

This commit is contained in:
Mark Wylde
2025-05-30 21:47:12 +01:00
parent c77bb0e4b3
commit c0d1a3fc4c
13 changed files with 468 additions and 878 deletions

View File

@@ -5,11 +5,11 @@
* Prevents automated tools or bots from triggering Claude
*/
import type { Octokit } from "@octokit/rest";
import type { GiteaApiClient } from "../api/gitea-client";
import type { ParsedGitHubContext } from "../context";
export async function checkHumanActor(
octokit: Octokit,
api: GiteaApiClient,
githubContext: ParsedGitHubContext,
) {
// Check if we're in a Gitea environment
@@ -26,9 +26,8 @@ export async function checkHumanActor(
try {
// Fetch user information from GitHub API
const { data: userData } = await octokit.users.getByUsername({
username: githubContext.actor,
});
const response = await api.customRequest("GET", `/api/v1/users/${githubContext.actor}`);
const userData = response.data;
const actorType = userData.type;

View File

@@ -1,15 +1,15 @@
import * as core from "@actions/core";
import type { ParsedGitHubContext } from "../context";
import type { Octokit } from "@octokit/rest";
import type { GiteaApiClient } from "../api/gitea-client";
/**
* Check if the actor has write permissions to the repository
* @param octokit - The Octokit REST client
* @param api - The Gitea API client
* @param context - The GitHub context
* @returns true if the actor has write permissions, false otherwise
*/
export async function checkWritePermissions(
octokit: Octokit,
api: GiteaApiClient,
context: ParsedGitHubContext,
): Promise<boolean> {
const { repository, actor } = context;
@@ -28,11 +28,7 @@ export async function checkWritePermissions(
core.info(`Checking permissions for actor: ${actor}`);
// Check permissions directly using the permission endpoint
const response = await octokit.repos.getCollaboratorPermissionLevel({
owner: repository.owner,
repo: repository.repo,
username: actor,
});
const response = await api.customRequest("GET", `/api/v1/repos/${repository.owner}/${repository.repo}/collaborators/${actor}/permission`);
const permissionLevel = response.data.permission;
core.info(`Permission level retrieved: ${permissionLevel}`);