如何在github动作工作流ci中通过npm安装私有github仓库

编程入门 行业动态 更新时间:2024-10-09 18:18:51

如何在github动作<a href=https://www.elefans.com/category/jswz/34/1770249.html style=工作流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中不提供的权限,则可以创建个人访问令牌并将其设置为存储库中的秘密:

  1. 使用或创建对该存储库具有适当权限的令牌。有关更多信息,请参见GITHUB_TOKEN
  2. 将令牌作为秘密添加到您的工作流存储库中,并使用"Creating a personal access token for the command line"语法对其进行引用。有关更多信息,请参见${{ secrets.SECRET_NAME }}

来源:"Creating and using encrypted secrets"

更多推荐

如何在github动作工作流ci中通过npm安装私有github仓库

本文发布于:2024-05-07 21:51:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1757415.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作流   仓库   动作   如何在   ci

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!