【问题标题】:GitHub action with access to private repo可访问私有仓库的 GitHub 操作
【发布时间】:2021-11-08 09:36:04
【问题描述】:

我想运行我的 Node / Ionic 项目的 CI 部分,我昨天刚刚在其中添加了一个自定义电容器插件 - repo A。

这个插件位于 repo B 中。

在我的开发机器上,我将 B 添加为

npm install https://PERSONAL_ACCESS_TOKEN@github.com/ME/B.git --save

到项目 A。

package.json 现在包含

"B": "git+https://PERSONAL_ACCESS_TOKEN@github.com/ME/B.git",

我将此推送到我当前的合并请求中。 然而,CI 管道现在告诉我:

  npm install
  shell: /usr/bin/bash -e {0}
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://***@github.com/ME/B.git
npm ERR! 
npm ERR! remote: Repository not found.
npm ERR! fatal: repository 'https://github.com/ME/B.git/' not found
npm ERR! 

项目 B 是一个私人仓库。我的帐户拥有两个存储库,并且我正在使用我新创建的个人访问令牌。

我应该检查什么?我可以在本地提取 repo,但是我也使用我的 git+ssh env 凭据进行了设置,所以它可能正因为如此......

【问题讨论】:

    标签: node.js github ionic-framework github-actions capacitor


    【解决方案1】:

    首先检查您是否需要您的 GitHub 用户名:

     https://myGitHubUsername:PERSONAL_ACCESS_TOKEN@github.com/ME/B.git
             ^^^^^^^^^^^^^^^^^
    

    那么,如果您需要git+https URL 中的令牌:

    How to use private GitHub repo as npm dependency”提到使用npm-cli-login代替:

    - name: Login to GitHub private NPM registry
      env:
        CI_ACCESS_TOKEN: ${{ secrets.NAME_OF_YOUR_ACCESS_TOKEN_SECRET }}
      shell: bash
      run: |
        npm install -g npm-cli-login
        npm-cli-login -u "USERNAME" -p "${CI_ACCESS_TOKEN}" -e "EMAIL" -r "https://npm.pkg.github.com" -s "@SCOPE"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-21
      • 2020-04-27
      • 2021-06-30
      • 2021-10-29
      • 2017-02-11
      • 1970-01-01
      • 2012-07-18
      • 2022-10-13
      相关资源
      最近更新 更多