I have a nodejs project that uses a private git repo as one of it’s dependencies. It’s defined in package.json like this:
"repo name": "git+https://{access_token}@github.com/{owner}/{repo name}.git#master"
My workflow file looks like this:
name: Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install modules
run: npm ci
- name: Run tests
run: npm test
npm ci
however fails with npm ERR! remote: Repository not found.
Using npm ci
on my local machine and on a clean ubuntu test machine works perfectly when I test it. I can’t figure out what’s causing this issue when on github actions.
I’ve read through many other forms but can’t find any solution that works or is applicable to my situation. If you have any ideas as to what may be causing this I’d be happy to hear your leads.
2
Answers
You can add this action after your checkout step and GitHub can access your private repo dependancy. But you should change your package name in package.json like below
Make sure to add a server’s private key as a secret, public key to GitHub SSH keys.
The auth token from
actions/checkout
is persisted. Therefore, it might be used again when fetching your npm dependency from GitHub, which doesn’t work.You can opt-out by passing the input
persist-credentials
like so: