Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Cloud Functions - private package in private repo? #2193

Closed
techieshark opened this issue Mar 4, 2021 · 7 comments
Closed

Google Cloud Functions - private package in private repo? #2193

techieshark opened this issue Mar 4, 2021 · 7 comments
Assignees
Labels
api: cloudfunctions Issues related to the Cloud Run functions API. samples Issues that are directly related to samples. type: question Request for information or clarification. Not an issue.

Comments

@techieshark
Copy link

Is there an example showing how to deploy a cloud function which makes use of a private modules (from a private code repo, hosted as part of GitHub package repository)?

This is somewhat similar to #300 but should probably be reopened since that it has been about four years and we now know that using private modules is possible but that example only covers NPM package repo, not GitHub.

Thanks!

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Mar 4, 2021
@fhinkel fhinkel added api: cloudfunctions Issues related to the Cloud Run functions API. type: question Request for information or clarification. Not an issue. labels Mar 4, 2021
@ace-n
Copy link
Contributor

ace-n commented Mar 4, 2021

@techieshark have you tried configuring your .npmrc file as shown here?

//npm.pkg.github.com/:_authToken=TOKEN

(I presume that the format of that file doesn't really differ between GitHub's registry and NPM's.)

@techieshark
Copy link
Author

@ace-n thanks for the response. Yes my .npmrc which is included in the deployed source is:

@myOrg:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=my-secret-auth-token

Unfortunately that doesn't work for me.

The full details of what I've tried and how it fails are shown here:

GoogleCloudPlatform/functions-framework-nodejs#258 (comment)

I've since then found this issue in the Google Issue Tracker, and the fact that it is still open makes me suspect that this is simply not something that the cloud functions team has made to work yet (if so, perhaps that could be documented?)

@ace-n
Copy link
Contributor

ace-n commented Mar 6, 2021

@techieshark thanks for the follow-up.

I've submitted a request internally to document this behavior.

cc @bcoe as FYI

@ace-n
Copy link
Contributor

ace-n commented Mar 6, 2021

Documentation updated. 🙂

(It may take a few days for the update to be publicly visible.)

Additionally, I'll pass this feedback along to the product team - in case they want to add it to the roadmap. (Unfortunately I can't say if or when that will happen, though.)

@ace-n ace-n closed this as completed Mar 6, 2021
@techieshark
Copy link
Author

Hi @ace-n - thanks or the super quick action! But... my apologies, but I may have been mistaken. 😬

After following up on a tip from @grant I was able to dig into this issue further and it seemed like the module was installed, but it was just a misleading log entry that made me believe it wasn't. I hope the additional info in the comment below is helpful to you and/or others:

GoogleCloudPlatform/functions-framework-nodejs#258 (comment)

@ace-n
Copy link
Contributor

ace-n commented Mar 9, 2021

@techieshark thanks for the follow-up, and I'm glad you were able to figure it out!

Given the issue you linked above (and the fact that I already updated the docs 🙂), I think more investigation is necessary. @bcoe is this something you can test out + report back on? (I don't have a private NPM repo handy.)

@ace-n ace-n reopened this Mar 9, 2021
@ace-n ace-n assigned bcoe and unassigned ace-n Mar 11, 2021
@bcoe
Copy link
Contributor

bcoe commented Apr 6, 2021

These steps work for me, is there anything that could be updated accordingly in the samples?

Using a Private Package in Cloud Function

  1. followed publishing a package tutorial, created the following automation:
  on:
  push:
      branches:
      - main
  name: release-please
  jobs:
  release-please:
      runs-on: ubuntu-latest
      steps:
      - uses: bcoe/release-please-action@v2
          id: release
          with:
          token: ${{ secrets.GITHUB_TOKEN }}
          release-type: node
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
          with:
          node-version: 14
      - run: npm install
      - uses: actions/setup-node@v1
          with:
          node-version: 14
          registry-url: https://npm.pkg.github.com/
          if: ${{ steps.release.outputs.release_created }}
      - run: npm install
          if: ${{ steps.release.outputs.release_created }}
      - run: npm publish
          env:
          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
          if: ${{ steps.release.outputs.release_created }}
  1. Created a repository with .npmrc in root:
  //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
  @bcoe:registry=https://npm.pkg.github.com
  1. Created access token with registry read permissions.
  2. Deployed function with gcloud with build environment variable GITHUB_TOKEN set to access token from prior step.
  3. accessed function.

@ace-n ace-n closed this as completed Apr 7, 2021
@ace-n ace-n reopened this Apr 7, 2021
@JustinBeckwith JustinBeckwith assigned ace-n and unassigned bcoe Aug 3, 2021
@ace-n ace-n closed this as completed Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: cloudfunctions Issues related to the Cloud Run functions API. samples Issues that are directly related to samples. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants