fix
This commit is contained in:
parent
84356f6fee
commit
9b859a65c7
@ -13,7 +13,8 @@ import { addPath, info, warning } from "@actions/core";
|
|||||||
import { isFeatureAvailable, restoreCache } from "@actions/cache";
|
import { isFeatureAvailable, restoreCache } from "@actions/cache";
|
||||||
import { downloadTool, extractZip } from "@actions/tool-cache";
|
import { downloadTool, extractZip } from "@actions/tool-cache";
|
||||||
import { getExecOutput } from "@actions/exec";
|
import { getExecOutput } from "@actions/exec";
|
||||||
import { writeBunfig, Registry } from "./bunfig";
|
import { Registry } from "./registry";
|
||||||
|
import { writeBunfig } from "./bunfig";
|
||||||
import { saveState } from "@actions/core";
|
import { saveState } from "@actions/core";
|
||||||
import { addExtension, retry } from "./utils";
|
import { addExtension, retry } from "./utils";
|
||||||
import { DownloadMeta, getDownloadMeta } from "./download-url";
|
import { DownloadMeta, getDownloadMeta } from "./download-url";
|
||||||
@ -172,11 +173,7 @@ async function downloadBun(
|
|||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
// Workaround for https://github.com/oven-sh/setup-bun/issues/79 and https://github.com/actions/toolkit/issues/1179
|
// Workaround for https://github.com/oven-sh/setup-bun/issues/79 and https://github.com/actions/toolkit/issues/1179
|
||||||
const zipPath = addExtension(
|
const zipPath = addExtension(
|
||||||
await downloadTool(
|
await downloadTool(downloadMeta.url, undefined, downloadMeta.auth),
|
||||||
downloadMeta.url,
|
|
||||||
undefined,
|
|
||||||
downloadMeta.auth ?? undefined,
|
|
||||||
),
|
|
||||||
".zip",
|
".zip",
|
||||||
);
|
);
|
||||||
const extractedZipPath = await extractZip(zipPath);
|
const extractedZipPath = await extractZip(zipPath);
|
||||||
|
|||||||
@ -40,9 +40,9 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
|||||||
await request(
|
await request(
|
||||||
`https://api.github.com/repos/oven-sh/bun/actions/workflows/ci.yml/runs?per_page=100&page=${page}`,
|
`https://api.github.com/repos/oven-sh/bun/actions/workflows/ci.yml/runs?per_page=100&page=${page}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: options.token
|
||||||
"Authorization": `Bearer ${options.token}`,
|
? { "Authorization": `Bearer ${options.token}` }
|
||||||
},
|
: {},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
).json()) as Runs)
|
).json()) as Runs)
|
||||||
@ -57,9 +57,9 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
|||||||
await request(
|
await request(
|
||||||
`https://api.github.com/repos/oven-sh/bun/actions/runs/${run.id}/artifacts`,
|
`https://api.github.com/repos/oven-sh/bun/actions/runs/${run.id}/artifacts`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: options.token
|
||||||
"Authorization": `Bearer ${options.token}`,
|
? { "Authorization": `Bearer ${options.token}` }
|
||||||
},
|
: {},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
).json()) as { artifacts: { name: string; archive_download_url: string }[] };
|
).json()) as { artifacts: { name: string; archive_download_url: string }[] };
|
||||||
@ -84,9 +84,9 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
|||||||
async function getSemverDownloadMeta(options: Input): Promise<DownloadMeta> {
|
async function getSemverDownloadMeta(options: Input): Promise<DownloadMeta> {
|
||||||
const res = (await (
|
const res = (await (
|
||||||
await request("https://api.github.com/repos/oven-sh/bun/git/refs/tags", {
|
await request("https://api.github.com/repos/oven-sh/bun/git/refs/tags", {
|
||||||
headers: {
|
headers: options.token
|
||||||
"Authorization": `Bearer ${options.token}`,
|
? { "Authorization": `Bearer ${options.token}` }
|
||||||
},
|
: {},
|
||||||
})
|
})
|
||||||
).json()) as { ref: string }[];
|
).json()) as { ref: string }[];
|
||||||
let tags = res
|
let tags = res
|
||||||
|
|||||||
@ -24,8 +24,9 @@ export async function request(
|
|||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
const res = await fetch(url, init);
|
const res = await fetch(url, init);
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
const body = await res.text().catch(() => "");
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to fetch url ${url}. (status code: ${res.status}, status text: ${res.statusText})\n${res}`,
|
`Failed to fetch url ${url}. (status code: ${res.status}, status text: ${res.statusText})${body ? `\n${body}` : ""}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user