Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I specify a gem to pull from a private github repository?

I have a private repository on Github that I want to use. I deploy my app to Heroku. How can I specify a private repository as the source on my gemfile? I imagine it wouldn't be enough to simply say

gem "mygem", :git=>"my github address"  
like image 837
picardo Avatar asked Jan 30 '11 01:01

picardo


People also ask

How do I grant access to a private repository on GitHub?

Under your repository name, click Settings. In the "Access" section of the sidebar, click Collaborators & teams. Click Invite a collaborator. In the search field, start typing the name of person you want to invite, then click a name in the list of matches.

Can GitHub read private repos?

Private repository data is scanned by machine and never read by GitHub staff. Human eyes will never see the contents of your private repositories, except as described in our Terms of Service. Your individual personal or repository data will not be shared with third parties.


1 Answers

The best way I've found to deploy a gem pulled from a private repo is to use GitHub's OAuth access. To do so:

  1. Create a GitHub user with access to the repo in question (best for teams – if you're okay exposing your personal access tokens, you can simply use your own account).

  2. Create an GitHub OAuth token for the user. It's dead simple to do this over the GitHub API just using curl; see the OAuth API for more.

  3. Add the token to the git url in your Gemfile. Example:

gem 'mygem', git: 'https://xxx123abc:[email protected]/user_or_team/mygem.git' 

I'm currently using this method on Heroku and it works great. The beauty is that you don't have to expose your own personal information, and you can revoke or regenerate the token at any point if something is compromised.

like image 64
Seth Bro Avatar answered Sep 28 '22 02:09

Seth Bro