yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.37k stars 2.72k forks source link

Github Runner with Private Repository as Dependency + SSH #8974

Open VladislavYakonyuk opened 10 months ago

VladislavYakonyuk commented 10 months ago

Hi, I'm having trouble working with GitHub private repositories in conjunction with yarn (c npm is exactly the same)

The stack is as follows: There is a github private repository which is a dependency for the main repository. A public ssh key was added to the dependency repository, which was generated on the server in deploy keys. In the github-runner, a private key was passed in secrets.

My package.json

"my-private-repo": "git+ssh://git@github.com:example/my-private-repo.git"

The secret key looks like this:

-----BEGIN RSA PRIVATE KEY-----
some key
-----END RSA PRIVATE KEY-----

The github-runner looks as follows:

      - name: build
        run: docker build -t frontend --build-arg SSH_KEY='${{{secrets.SSH_KEY}}' .

This is what the dockerfile looks like:

FROM node:16

ARG SSH_KEY

WORKDIR /app

COPY package.json /app/
COPY yarn.lock /app/

RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts

RUN yarn install # ssh-agent sh -c 'echo $SSH_KEY | base64 -d | ssh-add - ; yarn install'

This results in an error:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Can you tell me if I have made wrong steps somewhere?