我希望能够通过 Github Actions 在一个叫做 priv_gem_a
的 gem 上运行 rspec。
priv_gem_a
依赖于另一个在私有仓库中的 gem(叫做 priv_gem_b
)。然而,由于权限无效,我无法进行 priv_gem_b
的 bundle install。
错误:
Fetching gem metadata from https://rubygems.org/..........
Fetching git@github.com:myorg/priv_gem_b
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Host key verification failed.
Retrying `git clone 'git@github.com:myorg/priv_gem_b' "/opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/cache/bundler/git/priv_gem_b-886cdb130fe04681e92ab5365f7a1c690be8e62b" --bare --no-hardlinks --quiet` due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git@github.com:myorg/priv_gem_b' "/opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/cache/bundler/git/priv_gem_b-886cdb130fe04681e92ab5365f7a1c690be8e62b" --bare --no-hardlinks --quiet` in directory /home/runner/work/priv_gem_a/priv_gem_a has failed.
我认为这与在同一组织中的不同私有存储库无法访问有关。
因此,我尝试将环境变量添加到我的工作流文件中,包括 GITHUB_TOKEN
,但并没有起作用:
name: Test Code
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Install dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUNDLE_GITHUB__COM: ${{ secrets.GITHUB_TOKEN }}:x-oauth-basic
run: |
gem install bundler
gem update bundler
bundle install --without development --jobs 4 --retry 3
- name: Test with RSpec
run: |
bundle exec rspec
这只是来自Gemfile的一个片段:
gem 'priv_gem_b', '>= 7.0.1', '< 8', git: 'git@github.com:my_org/priv_gem_b', branch: :master
GITHUB_TOKEN
的澄清,现在我明白了!但是,我尝试了这种方法,但似乎没有获取到我的令牌(.../tokens旁边的新令牌显示为“从未使用”)。错误仍然相同。有什么想法吗? - Stefan Collier${{ secrets.THIS_DOES_NOT_EXIST }}
,它不会失败,因为它没有定义。 - Stefan Collier