![](/img/trans.png)
[英]Pulling private github repo set as dependency in package.json within docker generated failing in github actions
[英]Install private github package from package.json on Github Actions
我正在嘗試在我的項目中將 Github 操作作為 CI 實施。 問題是我在 package.json 上使用私有 git URL,但是 CI 出現錯誤,因為 Github 操作“以某種方式”無法訪問該存儲庫,這是不可能的,因為它位於同一個用戶帳戶上。
有誰知道如何解決這個問題?
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 install
存儲庫中的.npmrc
中。
例子:
//npm.pkg.github.com/:_authToken=**************
@youraccount:registry=https://npm.pkg.github.com
現在有一個專門的動作來自動設置 nodejs,它被稱為actions/setup-node
這里有一個例子:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '10.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
它創建了一個本地 .npmrc 文件,該文件使用環境變量來獲取身份驗證令牌:
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
@youraccount:registry=https://registry.npmjs.org
您可以使用 if 來定位任何私有注冊表,例如 GitHub 包
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.