skip to Main Content

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


  1. 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

    "some_package": "git+ssh://[email protected]:<Org_Name>/<Repo_Name>.git#<Branch_name>"
    

    Make sure to add a server’s private key as a secret, public key to GitHub SSH keys.

    Login or Signup to reply.
  2. 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:

    steps:
      - uses: actions/checkout@v2
        with:
          persist-credentials: false
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search