From f545a7c7188048dc27b523fb62b122e612849f2c Mon Sep 17 00:00:00 2001 From: Pedro Sousa <680496+pedrosousa@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:38:57 +0000 Subject: [PATCH] [Docs] Add support for GitHub token when fetching the Wrangler changelog --- src/util/changelogs.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/util/changelogs.ts b/src/util/changelogs.ts index dbab19dc9965b1b..c2f2341abb834fc 100644 --- a/src/util/changelogs.ts +++ b/src/util/changelogs.ts @@ -1,6 +1,7 @@ import { z } from "astro:schema"; import { getCollection } from "astro:content"; import { type CollectionEntry } from "astro:content"; +import { readFile } from "fs/promises"; export async function getChangelogs(opts?: { filter?: Parameters>[1]; @@ -60,8 +61,21 @@ export async function getChangelogs(opts?: { export async function getWranglerChangelog(): Promise< CollectionEntry<"changelogs"> > { + let authHeaders = {}; + + readFile("assets/secrets/github_tokens.txt", { encoding: "utf8" }) + .then((data) => { + authHeaders = { Authorization: `Bearer ${data.trim()}` }; + }) + .catch((_) => { + // console.log( + // "[GetWranglerChangelog] Info: No GitHub token found.", + // ); + }); + const response = await fetch( "https://api.github.com/repos/cloudflare/workers-sdk/releases", + { headers: authHeaders }, ); if (!response.ok) {