无法从远程存储库读取(Ruby on Rails)

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

我曾经通过 Github Actions 将代码从 Github 部署到 AWS,没有任何问题。但现在,同样的代码突然停止工作了。它给出了无法从远程存储库读取错误。我仍在尝试找出其原因。

我正在使用以下宝石。

  1. 宝石“capistrano-rails”
  2. gem 'capistrano', '~> 3.2'
  3. gem 'capistrano-rails-console',要求: false
  4. 宝石“capistrano-rails”
  5. 宝石'capistrano纱线'
  6. gem 'capistrano-bundler'
  7. gem“sshkit”,“1.18.2”
  8. gem“导轨”,“5.1.6.2”
  9. https://github.com/miloserdow/capistrano-deploy/tree/v2.2

Github Actions 代码:请注意,同样的代码运行得非常好。

name:  Deployment
on:
  workflow_dispatch:
jobs:
  deploy_to_xyz:
    name: Deploy to xyz
    runs-on: ubuntu-20.04
    env:
      CAP_BRANCH: zzz
      AWS_KEY_ID: xxxx
      AWS_SECRET_KEY:  xxxx
      AWS_REGION:  xxxx
    steps:
    - uses: actions/checkout@v2
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.5.9
        bundler-cache: true
    - uses: miloserdow/[email protected]
      with:
        target: staging
        enc_rsa_key_pth: "xxxx"
        deploy_key:  xxxx
    - name: Success
      # code related to  failure
    - name: Fail deploy notification
      # code related to  failure

它给出以下错误:

00:00 git:wrapper
      01 mkdir -p /tmp
    ✔ 01 [email protected]
    ✔ 01 user@xxxxxip 1.349s
      Uploading /tmp/git-ssh-xxxxx-runner.sh 100.0%
      Uploading /tmp/git-ssh-xxxxx-runner.sh 100.0%
      02 chmod 700 /tmp/git-ssh-xxxxx-runner.sh
    ✔ 02 user@xxxxxxIP 0.342s
    ✔ 02 user@xxxxxxIP 0.342s
00:02 git:check
      01 git ls-remote [email protected]:xxxx/xxxx.git HEAD
      01 ERROR: Repository not found.
      01 fatal: Could not read from remote repository.
      01
      01 Please make sure you have the correct access rights
      01 and the repository exists.
#<Thread:0x000055aecb8f72b0@/home/runner/work/xxxx/xxxx/vendor/bundle/ruby/2.5.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
/home/runner/work/xxxx/xxxx/vendor/bundle/ruby/2.5.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:15:in  rescue in block (2 levels) in execute : Exception while executing on host ip: git exit status: 128 (SSHKit::Runner::ExecuteError)
git stdout: Nothing written
git stderr: ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
    from /home/runner/work/xxxx/xxxx/vendor/bundle/ruby/2.5.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:11:in  block (2 levels) in execute 
      01 ERROR: Repository not found.
      01 fatal: Could not read from remote repository.
      01
      01 Please make sure you have the correct access rights
      01 and the repository exists.
#<Thread:0x000055aecb8f7738@/home/runner/work/xxxx/xxxx/vendor/bundle/ruby/2.5.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
/home/runner/work/xxxx/xxxx/vendor/bundle/ruby/2.5.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:15:in  rescue in block (2 levels) in execute : Exception while executing on host ip: git exit status: 128 (SSHKit::Runner::ExecuteError)
git stdout: Nothing written
git stderr: ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
    from /home/runner/work/xxxx/xxxx/vendor/bundle/ruby/2.5.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:11:in  block (2 levels) in execute 
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host ip: git exit status: 128
git stdout: Nothing written
git stderr: ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Caused by:
SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
git stderr: ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Tasks: TOP => deploy:check => git:check
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing on host ip: git exit status: 128
git stdout: Nothing written
git stderr: ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:
 INFO [8a54f66e] Running /usr/bin/env git ls-remote [email protected]:xxxx/xxxx.git HEAD on ip
 DEBUG [40ed32b1]   ERROR: Repository not found.
 DEBUG [40ed32b1]   fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
 DEBUG [5dd77983]   ERROR: Repository not found.
 DEBUG [5dd77983]   fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: Error: The process /opt/hostedtoolcache/Ruby/2.5.9/x64/bin/bundle failed with exit code 1

看起来它从 github actions 连接到远程服务器,但无法从 github 获取最新更改。

知道这个错误的原因是什么吗?

ruby-on-rails github amazon-ec2 github-actions capistrano
1个回答
0
投票

当我从 GitHub 的存储库中删除 Deploy 密钥时,我遇到了同样的问题。

另一个选项可以限制对 git 的访问

您可以使用服务器上的

ssh -T [email protected]
进行检查

© www.soinside.com 2019 - 2024. All rights reserved.