4

Working on local, pushing changes to Heroku works and the app works as expected. However I am having trouble linking heroku app to a private repo on Github.

Current configuration looks something like this

git@github.com:{Organization}/{project}.git

Where should I configure username/password for the private repo?

I tried (even though this is not the preferred way)

username:password@github.com/{organization}/{project}.git

would appreciate any pointers regarding this.

EDIT: I failed to mention that I am setting it under app settings in Heroku.

BinnyG
  • 601
  • 9
  • 19
  • Could you clarify what you mean by **linking** Github and Heroku? What are you expecting to happen? – nickgrim Oct 25 '12 at 12:40

2 Answers2

0
 git@github.com:{Organization}/{project}.git

This is an ssh address, with the authentication managed by public/private key: make sure your public key is published among the collaborators' keys for that Organization.
No "username" or "password" here.

username:password@github.com/{organization}/{project}.git

That could be correct if you use that remote address as an HTTPS address.


Note that Honza Javorek mentions in "How do I access a private github repo from heroku?" in Nov. 2020:

Heroku only supports HTTP(S) Basic authentication with Git out of the box.
That's unfortunate as it means you'd need to add your credentials as part of the installation URL and commit that as plain text in your list of dependencies.

He suggests to create a new GitHub SSH key and follow the heroku-buildpack-ssh-key process:

heroku buildpacks:add https://github.com/heroku/heroku-buildpack-ssh-key.git -i 1
heroku config:set BUILDPACK_SSH_KEY=$(cat ~/.ssh/id_rsa_heroku)
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    If I am setting the ssh address on my machine, how does setting it in heroku app settings help? I am trying to understand how this whole thing works. Would heroku push to github on my behalf or is my ssh client pushing it to both heroku github and my private github? – BinnyG Oct 25 '12 at 14:19
  • 1
    @BinnyG ok, just know that the second address you mentioned is an https one, not an ssh one. The push using the authentication attached to the remote GitHub repo address you will be using. If your app is developed locally (on your local workstation), then you can push it to Heroku (as in https://devcenter.heroku.com/articles/git) *and then* to GitHub repo (private or not). – VonC Oct 25 '12 at 14:30
  • Thanks for your quick and patient replies. I got that https part straight. If I understood it right I guess what you are saying it I have to manually push it to both Heroku and to my private/public repo on github independently. It makes sense and I am ok with that but I don't get the app settings part on heroku tho. How and where is that helping me? – BinnyG Oct 25 '12 at 14:36
  • @BinnyG not knowing the specifics of the "apps settings on Heroku", I wouldn't know just yet. My point was just that you can push both to Heroku and GitHub (without getting in details about *what* you are pushing). Note: you can push to two repos at the same time (http://stackoverflow.com/a/3195446/6309) – VonC Oct 25 '12 at 14:42
  • There is a setting under Heroku app settings which looks like this. [GitHub Repo: Link your app to a GitHub repository to see commit diffs in the activity log.] – BinnyG Oct 25 '12 at 15:13
  • @BinnyG ok, I didn't know that. Is it in the Heroku documentation? Both http://stackoverflow.com/questions/6963060/link-heroku-commits-to-github and http://stackoverflow.com/questions/2454661/heroku-and-github-integration-how-to-structure-the-project suggest Heroku is just another remote, like GitHub. – VonC Oct 26 '12 at 05:31
0

If you want to use a private repo, heroku needs to send github some sort of token as you know. If you create a deploy key on that private repo, you can use https://github.com/siassaj/heroku-buildpack-git-deploy-keys

sia
  • 1