chore: simplify action config
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
export const GITEA_API_URL =
|
||||
process.env.GITEA_API_URL || "https://api.github.com";
|
||||
|
||||
// Derive server URL from API URL for Gitea instances
|
||||
function deriveServerUrl(apiUrl: string): string {
|
||||
if (apiUrl.includes("api.github.com")) {
|
||||
return "https://github.com";
|
||||
// Derive API URL from server URL for Gitea instances
|
||||
function deriveApiUrl(serverUrl: string): string {
|
||||
if (serverUrl.includes("github.com")) {
|
||||
return "https://api.github.com";
|
||||
}
|
||||
// For Gitea, remove /api/v1 from the API URL to get the server URL
|
||||
return apiUrl.replace(/\/api\/v1\/?$/, "");
|
||||
// For Gitea, add /api/v1 to the server URL to get the API URL
|
||||
return `${serverUrl}/api/v1`;
|
||||
}
|
||||
|
||||
export const GITEA_SERVER_URL =
|
||||
process.env.GITEA_SERVER_URL || deriveServerUrl(GITEA_API_URL);
|
||||
process.env.GITHUB_SERVER_URL || "https://github.com";
|
||||
|
||||
export const GITEA_API_URL =
|
||||
process.env.GITEA_API_URL || deriveApiUrl(GITEA_SERVER_URL);
|
||||
|
||||
@@ -23,11 +23,11 @@ export async function setupGitHubToken(): Promise<string> {
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"No GitHub token available. Please provide a github_token input or ensure GITHUB_TOKEN is available in the workflow environment.",
|
||||
"No GitHub token available. Please provide a gitea_token input or ensure GITHUB_TOKEN is available in the workflow environment.",
|
||||
);
|
||||
} catch (error) {
|
||||
core.setFailed(
|
||||
`Failed to setup GitHub token: ${error}.\n\nPlease provide a \`github_token\` in the \`with\` section of the action in your workflow yml file, or ensure the workflow has access to the default GITHUB_TOKEN.`,
|
||||
`Failed to setup GitHub token: ${error}.\n\nPlease provide a \`gitea_token\` in the \`with\` section of the action in your workflow yml file, or ensure the workflow has access to the default GITHUB_TOKEN.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user