【问题标题】:GIthub action, authentication to git failedGIthub 操作,对 git 的身份验证失败
【发布时间】:2020-10-06 15:45:35
【问题描述】:

我有一个包含以下步骤的 GitHub 操作:

    - name: Install dependencies
      run: npm install
    - name: Build
      run: npm run build
    - name: Git config
      run: |
        git config user.email "my_email@gmail.com"
        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

> robertobatts.github.io@0.1.0 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! robertobatts.github.io@0.1.0 deploy: `gh-pages -b master -d build`
npm ERR! Exit status 1

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

【问题讨论】:

    标签: git github yaml github-pages github-actions


    【解决方案1】:

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

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

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

    with:
      github_token: ${{ secrets.GITHUB_TOKEN }}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-24
      • 2018-11-05
      • 1970-01-01
      • 2020-01-17
      • 1970-01-01
      • 1970-01-01
      • 2017-08-16
      • 2021-02-28
      相关资源
      最近更新 更多