Like many developers out there, we work on side projects from time to time. Sometimes it's to learn, to have fun or to make money. Regardless of the reason, we often throw in the towel due to burnout, loss of interest or that frustrating service/tool that should just work™ but doesn't.
I recently murmured "Why isn't this just working as stated!" while attempting to get Heroku to install my private Github packages. I headed to my trusty ol' friend, Google, to scour the internet for an answer only to be repeatedly told that I need to 'commit an .npmrc file' with the registry URL (with auth token) and getting absolutely nowhere.
On the verge of giving up, I decided to head into the Github actions source code. After all I was able to publish my package to my private Github registry in a CI environment.
Below is the code that dynamically creates the
.nmprc file before the Heroku build (using the
heroku-prebuild hook), using values from the environment variables.
The good stuff
auth-npm.jsscript to your project (I add it to my
Drop a comment below if you're running into trouble and/or if you have improvements!
Remember to #KeepHavingFun
Top comments (4)
Thanks for the article, although I am struggling getting this to work -- any examples of what GITHUB_SCOPE might look like? I am outputting the
contentsvariable after the fs.writeFileSync line and it looks like this:
this script is wrong
where is the
Probably way to late, but
fileLocationshould be the
npmrcvariable. Will update the script.
Heroku clearly documents how to do this but it simply doesn't work for my review app. Quite the head scratcher...