工作流ci中通过npm安装私有github仓库"/>
如何在github动作工作流ci中通过npm安装私有github仓库
我正在尝试通过运行npm install
在github工作流ci中安装npm依赖项。但是我得到以下错误:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://[email protected]/private-org/private-repo.git
npm ERR!
npm ERR! Warning: Permanently added the RSA host key for IP address 'removed' to the list of known hosts.
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
ci.yml
name: CI
on:
push:
branches: [master ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: node --version
- run: npm install
package.json
...
"dependencies": {
"some-pacakage": "git+ssh://[email protected]/private-org/private-repo.gitt",
},
...
此some-package
正在通过npm通过github安装。存储库与工作流所在的组织位于同一组织内。要在本地解决此问题,请在与该组织绑定的github帐户上设置ssh密钥。
但是我该如何解决这个问题,以便它能够通过工作流ci中的github repo安装该软件包,而即时通讯不使用我的个人github帐户。
回答如下:标准令牌没有足够的权限:
令牌的权限仅限于包含您的工作流程的存储库。有关更多信息,请参见"Permissions for the
GITHUB_TOKEN
"。
您必须手动创建一个可以访问软件包的个人访问令牌:
如果您需要令牌
GITHUB_TOKEN
中不提供的权限,则可以创建个人访问令牌并将其设置为存储库中的秘密:
- 使用或创建对该存储库具有适当权限的令牌。有关更多信息,请参见
GITHUB_TOKEN
。- 将令牌作为秘密添加到您的工作流存储库中,并使用"Creating a personal access token for the command line"语法对其进行引用。有关更多信息,请参见
${{ secrets.SECRET_NAME }}
。
来源:"Creating and using encrypted secrets"
更多推荐
如何在github动作工作流ci中通过npm安装私有github仓库
发布评论