【发布时间】:2021-05-21 23:46:21
【问题描述】:
我正在使用 Gatsby 和 Contentful 创建一个博客网站,用于学习目的。我想部署我的网站以使用 Github 操作来激增。我正在使用 gatsby-source-contentful 插件在构建时从 Contentful 获取我的内容。该插件需要spaceId 和accessToken 才能访问我的内容空间。在我的本地机器上进行开发期间,我使用保存在 .env 文件中的环境变量将这些值提供给插件。
但是,在 Github 操作的构建过程中,我收到此错误:
success open and validate gatsby-configs - 2.325s
error Invalid plugin options for "gatsby-source-contentful":
- "accessToken" is required
- "spaceId" is required
not finished load plugins - 1.002s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-contentful-blogsite@0.1.0 build: `tsc && gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-contentful-blogsite@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-02-18T17_53_11_281Z-debug.log
Error: Process completed with exit code 1.
有没有办法将这些环境变量(spaceId 和 accessToken)告知 Github 操作,以便可以成功配置 gatsby-source-contentful 插件?
【问题讨论】:
标签: environment-variables gatsby github-actions contentful