'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



Solution 1:[1]

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:[2]

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:[3]

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:[4]

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:[5]

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

Solution 6:[6]

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:[7]

For stop the heroku app uses :

$ heroku ps:scale web=0

And for start it uses :

$ heroku ps:scale web=1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris
Solution 2 ludovico
Solution 3 richard
Solution 4 Henry Ruhs
Solution 5 Leandro
Solution 6 Hakim Bawa
Solution 7 Dharmik Patel