Skip to content

Commit

Permalink
Introduce custom base url for runner
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianrath committed Feb 29, 2024
1 parent 1ec57c1 commit 33d742a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37871,6 +37871,9 @@ function run() {
const matrix = core.getInput("matrix") || ""; // matrix can be null
const baseUrl = `https://github.com/actionforge/${pj.name}/releases/download/v${pj.version}`;
const downloadUrl = `${runnerBaseUrl.replace(/\/$/, "") || baseUrl}/graph-runner-${os_1.default.platform()}-${os_1.default.arch()}.tar.gz`;
if (runnerBaseUrl) {
console.log("\u27a1 Custom runner URL set");
}
console.log("Downloading runner from", downloadUrl);
const downloadInfo = {
downloadUrl: downloadUrl,
Expand All @@ -37887,9 +37890,6 @@ function run() {
console.log(`${delimiter}`);
console.log(output);
console.log(`${delimiter}`);
if (runnerBaseUrl) {
console.log("\u2139 Custom runner URL set");
}
const runnerPath = yield downloadRunner(downloadInfo);
return executeRunner(runnerPath, graphFile, inputs, matrix);
});
Expand Down
20 changes: 10 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ export async function calculateFileHash(filePath: string): Promise<string> {
* @param info - The runner version information.
* @returns The path to the executable.
*/
async function downloadRunner(info: IRunnerVersionInfo): Promise<string> {
const token = core.getInput("token");
if (!token) {
throw new Error(`No GitHub token found`)
}

async function downloadRunner(info: IRunnerVersionInfo, token: string): Promise<string> {
const tempDir = process.env.RUNNER_TEMP || '.';
const filename = path.join(tempDir, info.filename);

Expand Down Expand Up @@ -140,8 +135,16 @@ async function run(): Promise<void> {
const inputs: string = core.getInput("inputs");
const matrix: string | null = core.getInput("matrix") || ""; // matrix can be null

const token = core.getInput("token");
if (!token) {
throw new Error(`No GitHub token found`)
}

const baseUrl = `https://github.com/actionforge/${pj.name}/releases/download/v${pj.version}`;
const downloadUrl = `${runnerBaseUrl.replace(/\/$/, "") || baseUrl}/graph-runner-${os.platform()}-${os.arch()}.tar.gz`;
if (runnerBaseUrl) {
console.log("\u27a1 Custom runner URL set");
}
console.log("Downloading runner from", downloadUrl);

const downloadInfo = {
Expand All @@ -165,10 +168,7 @@ async function run(): Promise<void> {
console.log(output);
console.log(`${delimiter}`);

if (runnerBaseUrl) {
console.log("\u2139 Custom runner URL set");
}
const runnerPath = await downloadRunner(downloadInfo);
const runnerPath = await downloadRunner(downloadInfo, token);
return executeRunner(runnerPath, graphFile, inputs, matrix);
}

Expand Down

0 comments on commit 33d742a

Please sign in to comment.