Skip to content

Commit

Permalink
[Docs] Add support for GitHub token when fetching the Wrangler changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrosousa committed Dec 20, 2024
1 parent ec828f0 commit f545a7c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/util/changelogs.ts
Original file line number Diff line number Diff line change
@@ -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<typeof getCollection<"changelogs">>[1];
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f545a7c

Please sign in to comment.