How to install private github repository via npm through "git+https" github actions workflow ci

I found the same problem with installing through git+https (How to install private github repository via npm in github actions workflow ci). According to our infrastructure requirements (we are using Docker, but build args are not supported now), I can’t create id_rsa on build stage :cry:.

According to the same topic, I got the following error on npm ci step:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ***github.com/org/private_repo.git
npm ERR! 
npm ERR! remote: Repository not found.
npm ERR! fatal: repository 'https://github.com/org/private_repo.git/' not found
npm ERR! 
npm ERR! exited with error code: 128

ci.yml

name: Test

on:
  pull_request:
    branches:
      - master
  push:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci
      - run: npm run lint
      - run: npm run test

package.json

"dependencies": {
  "@org/private-pkg": "git+https://token:x-oauth-basic@github.com/org/private_repo.git#tag"
}

This @org/private-pkg is being installed via github by npm on local machine and inside Docker. The repo is within the same organization as which the workflow is running in.

But how can I solve this issue with Github Actions?

Hi @aarefiev,

Glad to see you in Github Community Forum!

actions/checkout@v2 will persist GITHUB_TOKEN and add extra http header to latter git operations.

Please add persist-credential: false to actions/checkout@v2, and add below command before npm command:
run: git config --global url."https://${{ secrets.PAT }}@github.com/".insteadOf ssh://git@github.com/

Please refer to the link for more details.

Thanks.

1 Like