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

Enable download template from a private github repo using personal access token #5715

Merged
merged 2 commits into from Jan 22, 2019

Conversation

Projects
4 participants
@StevenACoffman
Copy link
Contributor

StevenACoffman commented Jan 17, 2019

What did you implement:

Closes #4566

  • When doing a serverless create, we can specify a template-url to fetch the template from a private github git repo HTTPS url using a personal access token. For instance:
mkdir mine
cd mine
npm init -f
npm install serverless --save-dev
SLS_DEBUG="*" npx serverless create --template-url https://x-access-token:${GITHUB_AUTH_TOKEN}@github.com/${PRIVATEFORKOWNER}/serverless/tree/master/lib/plugins/create/templates/aws-nodejs --name 'mine' --path mine

How did you implement it:

When URL.parse(inputUrl.replace(/\/$/, '')) is invoked, it saves the auth portion of the url object if found, but this is discarded when reconstructed using the existing template string.

How can we verify it:

  1. Make a private github repo, and push the serverless/serverless repo to it.
  2. You can manually check your personal access tokens out here https://github.com/settings/tokens and create a new one with "repo" scope. Save it somewhere because you can't get it again (but you can delete and recreate it). In your shell, export this value as the environment variable GITHUB_AUTH_TOKEN.
  3. Do this:
export GITHUB_AUTH_TOKEN='replacemewithyourtoken'
export PRIVATEFORKOWNER='replacewithyourgithubuser'
mkdir mine
cd mine
npm init -f
npm install serverless --save-dev
SLS_DEBUG="*" npx serverless create --template-url https://x-access-token:${GITHUB_AUTH_TOKEN}@github.com/${PRIVATEFORKOWNER}/serverless/tree/master/lib/plugins/create/templates/aws-nodejs --name 'mine' --path mine

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: Yes
Is it a breaking change?: NO

@StevenACoffman StevenACoffman changed the title Enable download template from a private repo Enable download template from a private github repo using personal access token Jan 17, 2019

@dschep dschep added this to In progress in Serverless via automation Jan 21, 2019

@dschep dschep self-assigned this Jan 21, 2019

Serverless automation moved this from In progress to Needs review Jan 21, 2019

@dschep
Copy link
Member

dschep left a comment

Could you apply the suggested change to fix the linting errors please?

Show resolved Hide resolved lib/utils/downloadTemplateFromRepo.js Outdated
Update lib/utils/downloadTemplateFromRepo.js
Co-Authored-By: StevenACoffman <StevenACoffman@users.noreply.github.com>
@dschep

dschep approved these changes Jan 22, 2019

Serverless automation moved this from Needs review to Reviewer approved Jan 22, 2019

@dschep dschep added this to the v1.36.3 milestone Jan 22, 2019

@dschep dschep merged commit 939d78b into serverless:master Jan 22, 2019

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.004%) to 93.011%
Details

Serverless automation moved this from Reviewer approved to Done Jan 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment