Redeploy Heroku app without code changes

Heroku

Heroku Problem Overview


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

Heroku Solutions


Solution 1 - Heroku

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.

Solution 2 - Heroku

You can do it from UI as well!

  1. Login to your Heroku dashboard and go to deploy section
  2. Find Manual deploy option

Hit Deploy Branch button!

enter image description here

Note: you must have your app connected to GitHub for this option to be available (see comment from Derek below).

Solution 3 - Heroku

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

Solution 4 - Heroku

> 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

Solution 5 - Heroku

You can run heroku restart --app app_name and you are good to go.

Solution 6 - Heroku

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:[email protected]/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

Solution 7 - Heroku

For stop the heroku app uses :

$ heroku ps:scale web=0

And for start it uses :

$ heroku ps:scale web=1

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnehemView Question on Stackoverflow
Solution 1 - HerokuChrisView Answer on Stackoverflow
Solution 2 - HerokuHardik RavalView Answer on Stackoverflow
Solution 3 - HerokurichardView Answer on Stackoverflow
Solution 4 - HerokuHenry RuhsView Answer on Stackoverflow
Solution 5 - HerokuLeandroView Answer on Stackoverflow
Solution 6 - HerokuHakim BawaView Answer on Stackoverflow
Solution 7 - HerokuUmeshView Answer on Stackoverflow