Linking heroku app to a private(organization) github repo

不羁的心 提交于 2021-02-07 07:57:58

问题


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.


回答1:


 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)



回答2:


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



来源:https://stackoverflow.com/questions/13066860/linking-heroku-app-to-a-privateorganization-github-repo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!