In the package.json
file, I have added a dependency that is referencing one of our public repositories. The dependency in the package.json
looks like below:
"ffprobe-static": "git https://github.com/company-name/repo-name.git",
I can successfully run npm install
locally and use this dependency, but when I push this code, our GitHub workflows where we execute npm install
fails with the below error:
npm ERR! Warning: Permanently added the RSA host key for IP address 'x.x.x.x' to the list of known hosts.
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
I don't understand the reason for this error, since the repository we are referencing is public, and also I can access the same repository when I install dependencies locally.
Note that the repository that is running this code is a private repository, but the referenced repository is public, but under the same organization.
CodePudding user response:
I was able to fix it by adding the below step after checkout in the YAML file. Also, set the persist-credentials
option to false in the checkout step.
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf
ssh://[email protected]/
CodePudding user response:
You might try a config to force https URLs, at least for testing, in your GitHub workflow:
- name: Fix URL access
run: echo -e '[url "https://github.com/"]\n insteadOf = "ssh://[email protected]/"' >> ~/.gitconfig
- name: Checkout server
uses: actions/checkout@v2
...
Or (as in here, just to illustrate where you can put the git config insteadOf
command):
on: push
jobs:
check-elm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
# From https://github.com/actions/checkout/issues/116#issuecomment-583221947
git config --global url."https://github.com/".insteadOf
ssh://[email protected]/
git submodule sync --recursive
git -c "http.extraheader=Authorization: basic ${{secrets.GITHUB_ACCESS_TOKEN}}" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- uses: actions/setup-node@v1
with:
node-version: '8.16.0'
- run: npm run test