Skip to content

Commit 45a911d

Browse files
committed
fix: add token to increase request limit
1 parent b05d304 commit 45a911d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

automation/utils/src/github.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { exec } from "./shell";
2-
import { fetch } from "./fetch";
31
import { mkdtemp, writeFile } from "fs/promises";
42
import { join } from "path";
3+
import { fetch } from "./fetch";
4+
import { exec } from "./shell";
55

66
interface GitHubReleaseInfo {
77
title: string;
@@ -80,13 +80,22 @@ export class GitHub {
8080
await exec(command);
8181
}
8282

83+
get ghAPIHeaders(): Record<string, string> {
84+
return {
85+
"X-GitHub-Api-Version": "2022-11-28",
86+
Authorization: `Bearer ${process.env.GH_PAT}`
87+
};
88+
}
89+
8390
async getReleaseIdByReleaseTag(releaseTag: string): Promise<string | undefined> {
8491
console.log(`Searching for release from Github tag '${releaseTag}'`);
8592
try {
8693
const release =
8794
(await fetch<{ id: string }>(
8895
"GET",
89-
`https://api.github.com/repos/mendix/web-widgets/releases/tags/${releaseTag}`
96+
`https://api.github.com/repos/mendix/web-widgets/releases/tags/${releaseTag}`,
97+
undefined,
98+
{ ...this.ghAPIHeaders }
9099
)) ?? [];
91100

92101
if (!release) {
@@ -115,7 +124,9 @@ export class GitHub {
115124
name: string;
116125
browser_download_url: string;
117126
}>
118-
>("GET", `https://api.github.com/repos/mendix/web-widgets/releases/${releaseId}/assets`);
127+
>("GET", `https://api.github.com/repos/mendix/web-widgets/releases/${releaseId}/assets`, undefined, {
128+
...this.ghAPIHeaders
129+
});
119130
}
120131

121132
async getMPKReleaseArtifactUrl(releaseTag: string): Promise<string> {

0 commit comments

Comments
 (0)