Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pass GitHub token to GraalPy queries
  • Loading branch information
msimacek committed Aug 29, 2023
commit 62fe528f261079161ed735fbc3dd5b49c99b1bd0
13 changes: 11 additions & 2 deletions src/install-graalpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import * as semver from 'semver';
import * as httpm from '@actions/http-client';
import * as ifm from '@actions/http-client/interfaces';
import * as exec from '@actions/exec';
import fs from 'fs';

Expand All @@ -16,6 +17,9 @@ import {
getBinaryDirectory
} from './utils';

const TOKEN = core.getInput('token');
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;

export async function installGraalPy(
graalpyVersion: string,
architecture: string,
Expand Down Expand Up @@ -55,7 +59,7 @@ export async function installGraalPy(
core.info(`Downloading GraalPy from "${downloadUrl}" ...`);

try {
const graalpyPath = await tc.downloadTool(downloadUrl);
const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH);

core.info('Extracting downloaded archive...');
downloadDir = await tc.extractTar(graalpyPath);
Expand Down Expand Up @@ -105,7 +109,12 @@ export async function getAvailableGraalPyVersions() {
const url = 'https://api.github.com/repos/oracle/graalpython/releases';
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');

const response = await http.getJson<IGraalPyManifestRelease[]>(url);
let headers: ifm.IHeaders = {};
if (AUTH) {
headers.authorization = AUTH;
}

const response = await http.getJson<IGraalPyManifestRelease[]>(url, headers);
if (!response.result) {
throw new Error(
`Unable to retrieve the list of available GraalPy versions from '${url}'`
Expand Down