1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 17:48:30 -04:00

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

This commit is contained in:
Jake Jarvis 2022-06-21 20:08:31 -04:00
parent a2f9b21886
commit 25b2e7133b
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39

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(