Pulling private github repo set as dependency in package.json within docker generated failing in github actions

Viewed 735

Expected behavior:
Github actions pipeline is triggered which then proceeds to build a docker image out of a dockerfile.
This dockerfile contains an npm install step that installs required packages listed in a package.json file.
One of the dependencies is a private github repo so it is required using the following format:

"packageName": "git+https://<auth token>:x-oauth-basic@github.com/orgName/packageName.git"

It should be installed without any issues and keep going with the dockerfile build process
Issue:
The dockerfile builds without issues locally but when I try to build it using github actions it outputs the following error :

npm ERR! code 128
npm ERR! command failed
npm ERR! command git ls-remote ssh://git@github.com/orgName/packageName.git
npm ERR! error: cannot run ssh: No such file or directory
npm ERR! fatal: unable to fork

Notes:
The whole docker image build process runs without issue locally so I really do not think it is a docker issue and more of a github restriction issue

1 Answers

If this works locally, check if your local git config -l includes any insteadOf directive, like:

git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "ssh://git@github.com/"

If so, check your GitHub workflow in order to include that configuration, as in mvdan/github-actions-golang for instance:

It's possible to install modules from private GitHub repositories without using your own proxy.
You'll need to add a personal access token as a secret environment variable.

- name: Configure git for private modules
 env:
   TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
 run: git config --global url."https://YOUR_GITHUB_USERNAME:${TOKEN}@github.com/".insteadOf "ssh://git@github.com/"
Related