【问题标题】:error "gatsby-source-github-api" threw an error while running the sourceNodes lifecycle: token is undefined错误“gatsby-source-github-api”在运行 sourceNodes 生命周期时抛出错误:令牌未定义
【发布时间】:2021-04-28 18:00:14
【问题描述】:

我是 Gatsby 的新手,今天刚刚为我的网站尝试了 GH Actions 工作流程。我在构建阶段看到了这个错误:

error "gatsby-source-github-api" 在运行 sourceNodes 生命周期:令牌未定义

我正在使用它来将我的 Github 上的所有 repos 拉入网站。

到目前为止我所尝试的:

  • 检查了 Github 个人访问令牌
  • 构建正在本地运行

版本:

“gatsby-source-github-api”:“^0.2.1”“gatsby”:“^2.26.1”

这是我的 node.js.yml GH Actions 工作流文件:

name: Node.js CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [13.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm ci
    - run: npm run build

PS:我使用 .env 文件来保存插件“gatsby-source-github-api”所需的令牌值。它在我的 .gitignore 文件中。那么这意味着它没有发送到 GH,因此找不到它?

【问题讨论】:

    标签: github gatsby


    【解决方案1】:

    就是这样——没有被推送到 Github 的 .env 文件。 所以我需要以某种方式使令牌可用于 GH Action 构建。 我尝试了SpicyPizza/create-envfile@v1 的操作。 Github 不支持它,但似乎可以完成这项工作。它使用您提供的密钥在构建时创建一个 .env 文件。

    您也可以手动创建 .env 文件。见thread

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-08
      • 2020-04-27
      • 2015-10-09
      • 2019-06-21
      • 2018-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多