mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-02-23 18:50:10 +08:00
fix: proper error when artifact is not found
This commit is contained in:
parent
65bc9b03e7
commit
bb5879294b
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -51,7 +51,7 @@ jobs:
|
||||
- "1"
|
||||
- "> 1.0.0"
|
||||
- "< 2"
|
||||
- "08a9b6a98b14d3c23b58080bea31513546246c50"
|
||||
- "dbd320ccfa909053f95be9e1643d80d73286751f"
|
||||
# Disable <sha> support for now. This is because Github Artifacts
|
||||
# expire after 90 days, and we don't have another source of truth yet.
|
||||
# - "822a00c4d508b54f650933a73ca5f4a3af9a7983" # 1.0.0 commit
|
||||
|
@ -39,7 +39,11 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
||||
(res = (await (
|
||||
await request(
|
||||
`https://api.github.com/repos/oven-sh/bun/actions/workflows/ci.yml/runs?per_page=100&page=${page}`,
|
||||
{}
|
||||
{
|
||||
headers: {
|
||||
"Authorization": `Bearer ${options.token}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
).json()) as Runs)
|
||||
) {
|
||||
@ -52,7 +56,11 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
||||
const artifacts = (await (
|
||||
await request(
|
||||
`https://api.github.com/repos/oven-sh/bun/actions/runs/${run.id}/artifacts`,
|
||||
{}
|
||||
{
|
||||
headers: {
|
||||
"Authorization": `Bearer ${options.token}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
).json()) as { artifacts: { name: string; archive_download_url: string }[] };
|
||||
|
||||
@ -62,9 +70,13 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
||||
avx2 ? "-baseline" : ""
|
||||
}${profile ? "-profile" : ""}`;
|
||||
|
||||
const artifact = artifacts.artifacts.find((item) => item.name === name);
|
||||
if (!artifact) {
|
||||
throw new Error(`Failed to find artifact '${name}' in run '${run.id}'`);
|
||||
}
|
||||
|
||||
return {
|
||||
url: artifacts.artifacts.find((item) => item.name === name)
|
||||
.archive_download_url,
|
||||
url: artifact.archive_download_url,
|
||||
auth: `Bearer ${token}`,
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user