GIthub操作,对git的身份验证失败

问题描述 投票:0回答:1

我有一个执行以下步骤的GitHub动作:

    - name: Install dependencies
      run: npm install
    - name: Build
      run: npm run build
    - name: Git config
      run: |
        git config user.email "[email protected]"
        git config user.name "my_username"
    - name: Deploy
      run: npm run deploy
      env:
        github_token: ${{ secrets.GITHUB_TOKEN }}

npm部署脚本所在的位置

gh-pages -b master -d build

所以我基本上是将构建从分支develop推送到master。部署脚本失败,因为它未正确验证git。这是错误:

Run npm run deploy

> [email protected] deploy /home/runner/work/robertobatts.github.io/robertobatts.github.io
> gh-pages -b master -d build

fatal: could not read Username for 'https://github.com': No such device or address

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: `gh-pages -b master -d build`
npm ERR! Exit status 1

secrets.GITHUB_TOKEN应该由GitHub自动创建,因为我已经设置了工作流程,所以我做错了什么?

git github yaml github-pages github-actions
1个回答
0
投票

我不确切知道您的特定操作,但是通常,如果令牌作为环境变量传递,则使用大写形式,例如:

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

或者如果作为参数传递,则使用with而不是env

with:
  github_token: ${{ secrets.GITHUB_TOKEN }}
© www.soinside.com 2019 - 2024. All rights reserved.