feat: support custom github url

Signed-off-by: Zoupers <qy@zouper.cn>
This commit is contained in:
Zoupers 2025-05-19 23:59:34 +08:00
parent 1417e89049
commit de3494511c
No known key found for this signature in database
GPG key ID: 6F77683A1BC51B5C
3 changed files with 16 additions and 1 deletions

View file

@ -24,6 +24,7 @@ export function tryGetFromToolCache(
}
export async function downloadVersion(
githubUrl: string,
platform: Platform,
arch: Architecture,
version: string,
@ -36,7 +37,7 @@ export async function downloadVersion(
if (platform === "pc-windows-msvc") {
extension = ".zip";
}
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}${extension}`;
const downloadUrl = `${githubUrl}/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}${extension}`;
core.info(`Downloading uv from "${downloadUrl}" ...`);
const downloadPath = await tc.downloadTool(

View file

@ -25,6 +25,7 @@ import {
toolDir,
version as versionInput,
workingDirectory,
githubUrl,
} from "./utils/inputs";
import * as exec from "@actions/exec";
import fs from "node:fs";
@ -95,6 +96,7 @@ async function setupUv(
}
const downloadVersionResult = await downloadVersion(
githubUrl,
platform,
arch,
resolvedVersion,

View file

@ -17,6 +17,7 @@ export const ignoreEmptyWorkdir =
core.getInput("ignore-empty-workdir") === "true";
export const toolBinDir = getToolBinDir();
export const toolDir = getToolDir();
export const githubUrl = getGithubUrl();
export const githubToken = core.getInput("github-token");
function getEnableCache(): boolean {
@ -84,3 +85,14 @@ function expandTilde(input: string): string {
}
return input;
}
function getGithubUrl(): string {
let url = "https://github.com";
if(process.env.GITHUB_URL) {
url = process.env.GITHUB_URL;
}
if(url.endsWith("/")) {
url = url.replaceAll(/\/+$/g, "")
}
return url;
}