【问题标题】:Laravel vapor github action throws permission errorLaravel vapor github 操作引发权限错误
【发布时间】:2021-09-14 05:29:07
【问题描述】:

我正在尝试使用 Github Actions 部署到 vapor。我正在使用https://docs.vapor.build/1.0/projects/deployments.html#deploying-from-ci 上描述的操作。

name: Deploy

on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.0
          tools: composer:v2
          coverage: none
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Require Vapor CLI
        run: composer global require laravel/vapor-cli
      - name: Deploy Environment
        run: vapor deploy
        env:
          VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}

由于此错误,github 操作不断失败:

Error Output:                                                                
  ================                                                             
  npm ERR! Error while executing:                                              
  npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/jawid-h/protobuf  
  .js.git                                                                      
  npm ERR!                                                                     
  npm ERR! Warning: Permanently added the RSA host key for IP address '140.82  
  .113.4' to the list of known hosts.                                          
  npm ERR! git@github.com: Permission denied (publickey).                      
  npm ERR! fatal: Could not read from remote repository.                       
  npm ERR!                                                                     
  npm ERR! Please make sure you have the correct access rights                 
  npm ERR! and the repository exists.                                          
  npm ERR!                                                                     
  npm ERR! exited with error code: 128

我已经尝试过传递 GITHUB_TOKEN,但不知何故不起作用。

【问题讨论】:

    标签: laravel github github-actions laravel-vapor


    【解决方案1】:

    这是一个 ssh 密钥错误。您使用的 ssh 密钥与您在 Github 中导入的密钥不同,或者它无法以某种方式访问​​。您需要检查~/.ssh/id_?sa 或手动指定另一个文件。

    如果您不需要写访问权限,也可以通过更改存储库 URL 来切换到匿名 https 协议:

    ssh://git@github.com/jawid-h/protobuf.js.git

    https://github.com/jawid-h/protobuf.js.git

    【讨论】:

      【解决方案2】:

      在我的情况下,我使用的是 GITLAB 平台,我得到了同样的错误。我通过删除“package-lock.json”解决了这个问题并运行了一个新的“npm install”。

      在 package-lock.json 中,您可以找到“lockfileVersion”这一行。

      解决问题前的版本:

      "lockfileVersion": 2,
      

      解决问题后的版本:

      "lockfileVersion": 1,
      

      【讨论】:

      • 作者的 ssh 密钥显然有问题,在您的情况下,您只是使用了 npm 6,而之前您使用的是 npm 7 或 npm 8
      猜你喜欢
      • 1970-01-01
      • 2014-11-29
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 2022-01-01
      • 2019-07-13
      • 1970-01-01
      • 2022-08-22
      相关资源
      最近更新 更多