在Github Actions上从package.json安装私有github包 [英] Install private github package from package.json on Github Actions

查看:100
本文介绍了在Github Actions上从package.json安装私有github包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Github动作作为CI实施在我的项目中.问题是我在package.json上使用了私有git URL,但是CI出现错误,因为Github操作以某种方式"无法访问该存储库,这是不可能的,因为它在同一用户帐户上.

I'm trying to implement Github actions as a CI on my project. The problem is that I'm using private git URL on my package.json but CI gets an error because Github actions "somehow" doesn't have access to that repo which it's impossible because it's on the same user account.

有人知道如何解决吗?

main.workflow 文件:

workflow "Github Actions" {
  on = "pull_request"
  resolves = ["Danger JS"]
}

action "Build" { <-------- This gets error
  uses = "actions/npm@master"
  args = "install"
}

action "Linter" {
  uses = "actions/npm@master"
  needs = "Build"
  runs = "lint"
}

action "Test" {
  needs = "Linter"
  uses = "actions/npm@master"
  args = "test"
}

action "Danger JS" {
  uses = "danger/danger-js@master"
  needs = ["Test"]
  secrets = ["DANGERJS_TOKEN"]
}

错误日志:

Successfully built xxxxxxxxxxxxx
Successfully tagged gcr.io/xxxxxxxxxxxxx
Pulling image: gcr.io/github-actions-development/action-runner:latest
latest: Pulling from github-actions-development/action-runner
xxxxxxxxxxxxx: Pulling fs layer
xxxxxxxxxxxxx: Verifying Checksum
xxxxxxxxxxxxx: Download complete
xxxxxxxxxxxxx: Pull complete
Digest: sha256:xxxxxxxxxxxxx
Status: Downloaded newer image for gcr.io/github-actions-development/action-runner:latest
npm ERR! code ENOGIT
npm ERR! Error while executing:
This package is on same user account but github actions doesn't have access anyhow ------> npm ERR! undefined ls-remote -h -t ssh://git@github.com/test-user/react-test-package.git 
npm ERR! 
npm ERR! undefined
npm ERR! No git binary found in $PATH
npm ERR! 
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! A complete log of this run can be found in:
npm ERR!     /github/home/.npm/_logs/2018-12-04T13_03_05_291Z-debug.log

### FAILED Build

推荐答案

您可以将对注册表具有读取权限的authToken放入运行 npm的存储库中的 .npmrc 中.安装.

You can put an authToken, which has read rights to the registry into a .npmrc in repository where you run npm install.

示例:

//npm.pkg.github.com/:_authToken=**************
@youraccount:registry=https://npm.pkg.github.com

这篇关于在Github Actions上从package.json安装私有github包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆