Skip to content

Commit f545a7c

Browse files
committed
[Docs] Add support for GitHub token when fetching the Wrangler changelog
1 parent ec828f0 commit f545a7c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/util/changelogs.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { z } from "astro:schema";
22
import { getCollection } from "astro:content";
33
import { type CollectionEntry } from "astro:content";
4+
import { readFile } from "fs/promises";
45

56
export async function getChangelogs(opts?: {
67
filter?: Parameters<typeof getCollection<"changelogs">>[1];
@@ -60,8 +61,21 @@ export async function getChangelogs(opts?: {
6061
export async function getWranglerChangelog(): Promise<
6162
CollectionEntry<"changelogs">
6263
> {
64+
let authHeaders = {};
65+
66+
readFile("assets/secrets/github_tokens.txt", { encoding: "utf8" })
67+
.then((data) => {
68+
authHeaders = { Authorization: `Bearer ${data.trim()}` };
69+
})
70+
.catch((_) => {
71+
// console.log(
72+
// "[GetWranglerChangelog] Info: No GitHub token found.",
73+
// );
74+
});
75+
6376
const response = await fetch(
6477
"https://api.github.com/repos/cloudflare/workers-sdk/releases",
78+
{ headers: authHeaders },
6579
);
6680

6781
if (!response.ok) {

0 commit comments

Comments
 (0)