Anyone who knows how I can install private npm pac...
# typescript
w
Anyone who knows how I can install private npm packages via github actions? I'm using a github ssh link
"foo-abc": "<git+ssh://git>@github.com/my-co/foo-abc.git#v1.0.1"
The relevant yaml for my github workflow looks like this:
Copy code
- name: setup ssh
        env:
          SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: |
          mkdir -p ~/.ssh
          ssh-keyscan <http://github.com|github.com> >> ~/.ssh/known_hosts
          ssh-agent -a $SSH_AUTH_SOCK > /dev/null
          ssh-add - <<< "${{ secrets.GH_PRIVATE_SSH }}"
      - name: npm install
        env:
          SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: npm install
m
I believe you need to generate a Personal Access Token with package read scope, and configure
.npmrc
and your
package.json
. https://blog.bitsrc.io/install-npm-private-packages-in-ci-cd-with-github-actions-746db95017cc
w
We won't publish to npm, but install via git ssh links. Thanks though ❤️
m
GitHub has a private package repository. You would be publishing your package to a private repository that another one of your private repositories could read from with the proper Personal Access Token scope
@white-rainbow-68240 have you considered this approach for your use case?
w
I will look into it. For now, I had the chance to open source the repo, so ended up publishing to npm as an open repo. If we need a private repo, I'd probably go with npm since alpine images don't have git installed. It just works better out-of-the-box with npm.
It's not really a hard problem, but most infra issues just take so much time to solve when you have 5 different services that all need to be integrated correctly.
m
I’m confused if you mean you’re going to publish your package publicly on npmjs.com — github also offers a private registry that you can use with the npm client https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages
w
That looks really interesting! I'll give it a chance as soon as we need to do something private.
Just having something a bit more integrated with github actions would make it all simpler
m
Yeah, using the github packages feature is that. Definitely worth looking into.