Deploy to heroku directly from my github repository - heroku

How can I deploy my app to Heroku directly from my GitHub remote repository?
Does a command for that exist, like this?
heroku push https://github.com/user/repository.git
Any tips? Tricks?

You can put services in between Github and Heroku which may achieve a similar result to what you want.
There are presently two addons in the Heroku Addon library which would be able to do this for you via Continuous Deployment.
Codeship.io (https://addons.heroku.com/codeship)
wercker (https://addons.heroku.com/wercker)
Basically, when you add and setup these addons they install a webhook into your projects github repo and then when you push to the repo, the webhook is triggered which triggers the service to grab your code (run tests if you want) and then push the code to Heroku.

Heroku recently added option to synchronize deployment with GitHub

There is no way to push from one git remote to another. You will have to clone from github and then push to heroku.

snap-ci is an easy way to setup a deployment pipeline from Github to Heroku

git clone git://github.com/heroku/ruby-sample.git
cd ruby-sample
heroku create
git push heroku master
heroku open
It was as default example from heroku. You can get an idea. right ?

Create a 'Deploy to Heroku' button and include in the README - https://devcenter.heroku.com/articles/heroku-button

Related

setup remote heroku repo on source tree

I'm trying to use Source Tree to push to Heroku. I've installed the Heroku CLI, so in order to clone an existing repo from Heroku, I just need to login through the terminal and it works, but if I have to push, I always get a permission denied.
So I'm wondering if I need to setup something in Source Tree as I've done for my Github repo. but in settings > account... I can only pick Github or Bitbucket. So how can I authenticate and push to Heroku?
Thanks

Linking my Heroku app to GitHub

I have an app on Heroku and I want to link it to github. I've tried some suggestions found on here. For example
git remote add heroku git#heroku.com:<app name>.git
but I get
fatal: remote heroku already exists.
What do I need to do?
Heroku waits for a new push from Github before deploying. You have to first push to Github, and then connect your repository to Heroku.

Redeploy Heroku app without code changes

I would like to deploy a Heroku app which will be done ideally using git push -u heroku master. However this will only work if there are any pending commits to be pushed to master.
How can I redeploy the app while there is nothing to push ? I tried git push -u heroku master -f and still get the same below
Branch master set up to track remote branch master from heroku.
Everything up-to-date
PS: I also want to retain the existing app, which means I cannot make use of this answer https://stackoverflow.com/a/22043184/968442
Normally setting a config var causes your application to be restarted. In most situations there should be no need to redeploy after doing this.
If you really do need to trigger a new deployment you can add a new empty commit, then push to Heroku again:
git commit --allow-empty -m "Trigger Heroku deploy after enabling collectstatic"
git push heroku master
The new empty commit is a regular commit. It has a hash, an author, a timestamp, etc. It will have the same tree as its parent. This should cause Heroku to build your app slug again using the same code as the previous commit.
It's a bit awkward, but it works.
You can do it from UI as well!
Login to your Heroku dashboard and go to deploy section
Find Manual deploy option
Hit Deploy Branch button!
Note: you must have your app connected to GitHub for this option to be available (see comment from Derek below).
There is now also a plugin for the Heroku command-line that allows you to re-release the most recently deployed slug.
See https://www.npmjs.com/package/heroku-releases-retry
It turns out there is a neat plugin for Heroku called heroku release retry that lets you retry the last deploy without resorting to adding bad commits to your repository.
// install plugin
heroku plugins:install heroku-releases-retry
// retry release
heroku releases:retry --app {your-app}
Source: https://www.darraghoriordan.com/2019/03/02/heroku-push-failed-force-rebuild
You can run heroku restart --app app_name and you are good to go.
This worked for me, it did an actual build and release without any commit, contrary to one other post that only does a release:
heroku plugins:install heroku-builds
heroku builds:create --source-url https://user:token#api.github.com/repos/<username>/<repo name>/tarball/master/ --app <app-name>
Source: https://help.heroku.com/I3E6QPQN/how-do-i-force-a-new-deploy-without-adding-a-commit-to-my-github-repo
For stop the heroku app uses :
$ heroku ps:scale web=0
And for start it uses :
$ heroku ps:scale web=1

Deploying to heroku using bit bucket repo

I currently have a private repo on bitbucket which i would like to deploy to heroku.
Been looking around but finding it difficult to find any related info.
Can anyone assist
Thanks
The fact you are hosting the repository on BitBucket, as opposed to GitHub or GitLab, makes no difference.
Just follow the deploying with Git support page from Heroku.
You simply need to create the application (unless you have one):
$ heroku create
At that point you should have the Heroku git remote URL:
$ git remote -v
Then you can deploy:
$ git push heroku master
Please make sure to read the article I linked as it contains a more detailed explanation.

Deploying Angular-fullstack app on Heroku using Codeship

I'm trying to deploy a website via CodeShip unto Heroku. The site is built with Yeoman's Angular-Fullstack generator, which is pushed to GitHub. Codeship detects the push, builds the entire thing and then the trouble start.
Angular-Fullstack is set up so that the dist/ folder contains the entire Heroku app, so blindly deploying everything will not work on Heroku.
Locally, I can use the Heroku toolbelt to login, add a remote inside the dist folder, and then use grunt buildcontrol to deploy the entire thing unto Heroku.
But in Codeship there are a few caveats:
* I cannot install the Heroku toolbelt with wget because it needs sudo and Codeship doesn't support that
* If I could, I couldn't login to Heroku using the CLI because I cannot interact with the shell in Codeship
* I cannot go into the dist/ folder and after adding the remote, simply push to Heroku because I need to enter my credentials.
Is there a way that I missed here? I'd like to let Codeship handle everything from building to deployment to Heroku (only on the master branch).
Figured it out!
I skipped the step where I was trying to install the Heroku Toolbelt, and just added the repo on Heroku as remote:
git remote add heroku ssh://git#heroku.com/[your-heroku-app-name].git
Codeship has public keys available for every build. So, I added that publick key to my Heroku account.
Then I noticed that Git was still trying to push using HTTPS instead of SSH, so I added this to the deployment script:
git config --global url.ssh://git#heroku.com/.insteadOf https://git.heroku.com/
This made sure that Git uses the SSH url for Heroku. I then let Codeship build the entire project and push it with grunt buildcontrol:heroku.

Resources