mirror of
https://github.com/actions/setup-python.git
synced 2025-04-21 02:39:15 +08:00
Pass GitHub token to GraalPy queries
This commit is contained in:
parent
3d8a1eb795
commit
62fe528f26
|
@ -4,6 +4,7 @@ import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as httpm from '@actions/http-client';
|
import * as httpm from '@actions/http-client';
|
||||||
|
import * as ifm from '@actions/http-client/interfaces';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
|
@ -16,6 +17,9 @@ import {
|
||||||
getBinaryDirectory
|
getBinaryDirectory
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
|
const TOKEN = core.getInput('token');
|
||||||
|
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;
|
||||||
|
|
||||||
export async function installGraalPy(
|
export async function installGraalPy(
|
||||||
graalpyVersion: string,
|
graalpyVersion: string,
|
||||||
architecture: string,
|
architecture: string,
|
||||||
|
@ -55,7 +59,7 @@ export async function installGraalPy(
|
||||||
core.info(`Downloading GraalPy from "${downloadUrl}" ...`);
|
core.info(`Downloading GraalPy from "${downloadUrl}" ...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const graalpyPath = await tc.downloadTool(downloadUrl);
|
const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
||||||
|
|
||||||
core.info('Extracting downloaded archive...');
|
core.info('Extracting downloaded archive...');
|
||||||
downloadDir = await tc.extractTar(graalpyPath);
|
downloadDir = await tc.extractTar(graalpyPath);
|
||||||
|
@ -105,7 +109,12 @@ export async function getAvailableGraalPyVersions() {
|
||||||
const url = 'https://api.github.com/repos/oracle/graalpython/releases';
|
const url = 'https://api.github.com/repos/oracle/graalpython/releases';
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
|
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) {
|
if (!response.result) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to retrieve the list of available GraalPy versions from '${url}'`
|
`Unable to retrieve the list of available GraalPy versions from '${url}'`
|
||||||
|
|
Loading…
Reference in a new issue