From 25b2e7133b9e17a47cbb36beeefa4f8411bd1121 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Tue, 21 Jun 2022 20:08:31 -0400 Subject: [PATCH] don't fail the entire build if `GH_PUBLIC_TOKEN` isn't set --- pages/projects.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pages/projects.tsx b/pages/projects.tsx index d59afc53..68157108 100644 --- a/pages/projects.tsx +++ b/pages/projects.tsx @@ -71,6 +71,17 @@ const Projects = ({ repos }: { repos: Repository[] }) => { }; export const getStaticProps: GetStaticProps = async () => { + // don't fail the entire site build if the required API key for this page is missing + if (typeof process.env.GH_PUBLIC_TOKEN === "undefined" || process.env.GH_PUBLIC_TOKEN === "") { + console.warn(`ERROR: I can't fetch any GitHub projects without "GH_PUBLIC_TOKEN" set! Skipping for now...`); + + return { + props: { + repos: [], + }, + }; + } + // https://docs.github.com/en/graphql/reference/objects#repository // eslint-disable-next-line @typescript-eslint/no-explicit-any const response: any = await graphql(