Ste*_*ier 6 ruby rubygems github-api github-actions
我想priv_gem_a
通过github操作在gem上运行rspec(称之为)。
priv_gem_a
取决于私人仓库中的另一个宝石(称为priv_gem_b
)。但是priv_gem_b
由于权限无效,我无法捆绑安装。
错误:
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.
Run Code Online (Sandbox Code Playgroud)
我认为这与跑步者无法访问同一组织中不同的私有存储库有关。
因此,我尝试将环境变量添加到我的工作流文件include 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
Run Code Online (Sandbox Code Playgroud)
来自Gemfile的一小段与此有关:
gem 'priv_gem_b', '>= 7.0.1', '< 8', git: 'git@github.com:my_org/priv_gem_b', branch: :master
Run Code Online (Sandbox Code Playgroud)
我相当确定GITHUB_TOKEN
存储库中的默认密码仅适用于该存储库。您不能使用它来访问其他存储库。
尝试repo
改为使用作用域标记。在https://github.com/settings/tokens上创建一个,然后作为秘密添加到您的工作流运行所在的存储库中。该文件位于https://github.com/ [用户名] / [repo] / settings下/秘密
在工作流程中使用该机密而不是GITHUB_TOKEN
。
BUNDLE_GITHUB__COM: ${{ secrets.REPO_SCOPED_TOKEN }}:x-oauth-basic
Run Code Online (Sandbox Code Playgroud)
或者,使用x-access-token
我认为更可取的方法。
BUNDLE_GITHUB__COM: x-access-token:${{ secrets.REPO_SCOPED_TOKEN }}
Run Code Online (Sandbox Code Playgroud)
另外,我认为您需要更改对私有gem的引用,以便它使用HTTPS。现在,您引用它的方式意味着它将尝试使用SSH密钥而不是中定义的令牌BUNDLE_GITHUB__COM
。
gem 'my_private_repo', git: 'https://github.com/username/my_private_repo.git'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
321 次 |
最近记录: |