I would like to run the CI part of my Node / Ionic project where I just yesterday added a custom capacitor plugin - repo A.
This plugin sits in repo B.
On my dev machine I added B as
npm install https://PERSONAL_ACCESS_TOKEN@github.com/ME/B.git --save
to project A.
package.json
now contains
"B": "git+https://PERSONAL_ACCESS_TOKEN@github.com/ME/B.git",
and I pushed this to my current merge request. However, the CI pipeline is telling me now:
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!
Project B is a private repo. My account owns both repos and I am using my newly created Personal Access Token.
What should I check? I can pull the repo on my local, but there I am setup with my git+ssh env credentials too, so it might work just because of that...
Check first if you need your GitHub username:
https://myGitHubUsername:PERSONAL_ACCESS_TOKEN@github.com/ME/B.git
^^^^^^^^^^^^^^^^^
Then, if you need the token in the git+https
URL:
" How to use private GitHub repo as npm dependency " mentions the use of npm-cli-login
instead:
- 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"
Most answers that I have seen to install private GitHub repo
"package": "git+https://PERSONAL_ACCESS_TOKEN:x-oauth-basic@github.com/username/packge.git"
or
"package": "https://PERSONAL_ACCESS_TOKEN:x-oauth-basic@github.com/username/packge.git"
This works in local, however, if you are using actions/checkout@v2
in your github Action then you need to use persist-credentials:false
like the following.
- uses: actions/checkout@v2
with:
persist-credentials: false
otherwise, you'll get an error message remote: Repository not found.
other ways to install private github repo
if you are using ssh
like following
"package": "git+ssh://git@github.com/username/packge.git"
then you have to use the ssh-agent in your github action like this
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
here SSH_PRIVATE_KEY
is a private key from public-private key pair generated using ssh-keygen
and the public key is added as a deploy key in the private repo that you are trying to install as an npm package. for more information about this, you can check the official doc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.