1

I have an GitHub Repo with some testing workflows:

name: Tests the App

on:
  push:
    branches: [main]

jobs:
  test:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: "npm"
    - run: echo "Testing App."
    - run: npm install
    - run: echo "Using ESLint."
    - run: npm run lint
    - run: echo "Testing App."
    - run: npm run test
    - run: echo "Test completed!"

Unfortunately it throws an git error with exit code 128:

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/MYNAME/REPONAME.git
npm ERR! Warning: Permanently added the RSA host key for IP address 'SOMEIPADDR' 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.
[…]
Error: Process completed with exit code 128.

When it tries to npm install the dependencies there is a private GitHub Repo REPONAME which needs to be installed from my account.

"dependencies": {
   "pckgname": "git+ssh://[email protected]:MYNAME/REPONAME.git#main"
}

What's the best way to make this work in ci/cd environments?

1 Answer 1

2

You could use webfactory/[email protected]. First thing you would do is create an SSH key pair in the REPONAME.git repository, (preferably dedicated for Github actions), then put the private key as a secret in Github Actions, for this example we'll call it SSH_PRIVATE_KEY, then simply update your workflow like this:

 steps:
    - uses: actions/checkout@v2
    - uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
    - ...

Further details on this action here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.