mirror of
https://github.com/markwylde/claude-code-gitea-action.git
synced 2026-02-20 02:22:49 +08:00
Attempt to make this work
This commit is contained in:
@@ -14,19 +14,53 @@ export async function checkWritePermissions(
|
||||
): Promise<boolean> {
|
||||
const { repository, actor } = context;
|
||||
|
||||
core.info(
|
||||
`Environment check - GITEA_API_URL: ${process.env.GITEA_API_URL || "undefined"}`,
|
||||
);
|
||||
core.info(`API client base URL: ${api.getBaseUrl?.() || "undefined"}`);
|
||||
|
||||
// For Gitea compatibility, check if we're in a non-GitHub environment
|
||||
const giteaApiUrl = process.env.GITEA_API_URL?.trim();
|
||||
const isGitea =
|
||||
process.env.GITEA_API_URL &&
|
||||
!process.env.GITEA_API_URL.includes("api.github.com");
|
||||
giteaApiUrl &&
|
||||
giteaApiUrl !== "" &&
|
||||
!giteaApiUrl.includes("api.github.com") &&
|
||||
!giteaApiUrl.includes("github.com");
|
||||
|
||||
if (isGitea) {
|
||||
core.info(`Detected Gitea environment, assuming actor has permissions`);
|
||||
core.info(
|
||||
`Detected Gitea environment (${giteaApiUrl}), assuming actor has permissions`,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Also check if the API client base URL suggests we're using Gitea
|
||||
const apiUrl = api.getBaseUrl?.() || "";
|
||||
if (
|
||||
apiUrl &&
|
||||
!apiUrl.includes("api.github.com") &&
|
||||
!apiUrl.includes("github.com")
|
||||
) {
|
||||
core.info(
|
||||
`Detected non-GitHub API URL (${apiUrl}), assuming actor has permissions`,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we're still here, we might be using GitHub's API, so attempt the permissions check
|
||||
core.info(
|
||||
`Proceeding with GitHub-style permission check for actor: ${actor}`,
|
||||
);
|
||||
|
||||
// However, if the API client is clearly pointing to a non-GitHub URL, skip the check
|
||||
if (apiUrl && apiUrl !== "https://api.github.com") {
|
||||
core.info(
|
||||
`API URL ${apiUrl} doesn't look like GitHub, assuming permissions and skipping check`,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
core.info(`Checking permissions for actor: ${actor}`);
|
||||
|
||||
// Check permissions directly using the permission endpoint
|
||||
const response = await api.customRequest(
|
||||
"GET",
|
||||
|
||||
Reference in New Issue
Block a user