don't fail the entire build if GH_PUBLIC_TOKEN isn't set

This commit is contained in:
jake committed 2022-06-21 20:08:31 -04:00
1 parent a2f9b21886
commit 25b2e7133b
1 file changed
+11
+11
View File
@@ -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(