Update action.ts
This commit is contained in:
parent
44bbd277f2
commit
39c33841fd
@ -18,6 +18,7 @@ import { saveState } from "@actions/core";
|
|||||||
import { addExtension, extractVersionFromUrl, getCacheKey } from "./utils";
|
import { addExtension, extractVersionFromUrl, getCacheKey } from "./utils";
|
||||||
import { getDownloadUrl } from "./download-url";
|
import { getDownloadUrl } from "./download-url";
|
||||||
import { cwd } from "node:process";
|
import { cwd } from "node:process";
|
||||||
|
import { verifyAsset } from "./verify";
|
||||||
|
|
||||||
export type Input = {
|
export type Input = {
|
||||||
customUrl?: string;
|
customUrl?: string;
|
||||||
@ -121,7 +122,7 @@ export default async (options: Input): Promise<Output> => {
|
|||||||
|
|
||||||
if (!cacheHit) {
|
if (!cacheHit) {
|
||||||
info(`Downloading a new version of Bun: ${url}`);
|
info(`Downloading a new version of Bun: ${url}`);
|
||||||
revision = await downloadBun(url, bunPath);
|
revision = await downloadBun(url, bunPath, options.token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,9 +178,15 @@ function isVersionMatch(
|
|||||||
async function downloadBun(
|
async function downloadBun(
|
||||||
url: string,
|
url: string,
|
||||||
bunPath: string,
|
bunPath: string,
|
||||||
|
token?: string,
|
||||||
): 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(await downloadTool(url), ".zip");
|
const zipPath = addExtension(await downloadTool(url), ".zip");
|
||||||
|
|
||||||
|
// INTEGRITY CHECK: Verify the download before extraction.
|
||||||
|
// This checks the Local Hash, GitHub Asset Digest, and the robobun PGP Signature.
|
||||||
|
await verifyAsset(zipPath, url, token);
|
||||||
|
|
||||||
const extractedZipPath = await extractZip(zipPath);
|
const extractedZipPath = await extractZip(zipPath);
|
||||||
const extractedBunPath = await extractBun(extractedZipPath);
|
const extractedBunPath = await extractBun(extractedZipPath);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user