How to reset/revert Heroku Config? - heroku

Since each time you add a key/value using heroku config:add it returns a version, is it possible to revert to an older version?
If not, is it possible to clear all of the heroku config, since I've got a local .env that I'd like to push, but it does not clean out the other variables.
Reason I cannot use heroku config:unset is because of some bug, I was able to put an empty key there.
: true
Not I can't get rid of it, and the build keeps failing -_-'
** UPDATE **
just found heroku releases

Running heroku rollback would rollback to the previous release, and you can also specify an older version with it. The full heroku docs have more on this - https://devcenter.heroku.com/articles/releases#rollback

https://devcenter.heroku.com/articles/releases#rollback
It will give more details of release.
$ heroku releases:info v24
v24 is your release name, which can vary accordingly.

Related

heroku finds an old project that i ave deleted on my heroku homepages

When I try to disable static files on Heroku it keeps linking to a previous project. However, I deleted all my Heroku projects so there are none in my account.
How is this possible and how do I fix it? The heroku CLI seems to be trying to find vast-depths-55781 but the project I just created is immense-ridge-40969:
Heroku determines which app it should use based on your configured Git remotes.
Run git remote -v to see which ones you have set up; I suspect you'll see one pointing to vast-depths-59781. Remove it by its name, e.g.
git remote remove heroku
You could manually add a remote for your new app (or have just changed the previous one's URL), but Heroku provides a dedicated command for setting this up:
heroku git:remote --app immense-ridge-40969
Now heroku commands should default to the new app in that folder. (You can always provide the --app argument to tell heroku to operate against a different app if you wish.)

How to stop deployment to Heroku in progress

Is it possible to stop a deploy to Heroku (git push heroku) that is currently being built?
Something like heroku run stopit!
Btw. rolling back after successful deploy is not what I'm looking for.
First, install the Heroku builds plugin:
heroku plugins:install heroku-builds
Then, to cancel a build, fetch the list of the recent builds:
heroku builds -a YOUR_APP_NAME
The first line of the output will be your currently running build, the first column is the build ID.
Cancel it with:
heroku builds:cancel BUILD_ID -a YOUR_APP_NAME
Et voilĂ , this will force fail the build.
Note: you could also get the build id from the build log URL.
I might have found an answer to this problem, it seems to have been answered by Heroku in May. I'm assuming that by release phase they mean deploy:
https://help.heroku.com/Z44Q4WW4/how-do-i-stop-a-release-phase
Release Phase processes are the same as any other Dyno in your formation, expect they run the codebase from the new release, instead of your current release.
To monitor your Release Phase processes as they execute, you can use the CLI command heroku ps -a YOUR_APP_NAME. as these are normal processes, you can use the ps:kill and ps:scale commands to stop the Release Phase from completing, which in turn, will prevent the latest release from completing.
I haven't tested this yet, but i will update with my exact commands when i have tested it out. If any one tests this out and can confirm, please feel free to update this answer.
I used the command
heroku builds:cancel -a <your_app_name>
and this worked for me

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

How do you force a deploy to Heroku without doing a git commit

I had a case where a push to heroku failed because of a database issue. I fixed it, but the only way I know to deploy is via "git push heroku master". Since I didn't commit anything, it won't push a new deployment. The only way I can get it to deploy to make some minor change and then do it. Is there a way to force a deploy? I'm using play 2.1.2.
You could try a throw-away commit if you concern is to avoid actually saving the 'minor/dummy' commits to the repo permanently:
Heroku Throwaway Commit
See Section: "Automating the throwaway commit"
The author has basically automated the above with a quick bash script; however, as the author indicates use with caution -- you wouldn't want to use this in other situations with un-tested code.
https://www.darraghoriordan.com/2019/03/02/heroku-push-failed-force-rebuild/
heroku plugins:install heroku-releases-retry
heroku releases:retry
# or
heroku releases:retry --app darragh-starter
If you are just trying to reload the dynos you can issue this from the command line:
heroku restart -a appname
More info https://devcenter.heroku.com/articles/application-offline

Upgrading from Heroku Bamboo stack to a Cedar stack

I am upgrading my app from Rails 3.0 to Rails 3.1. To do this I need to upgrade my Heroku stack to Cedar rather than Bamboo which is currently on.
I am going through the following tutorial
and am getting stuck at the part where I deploy git push heroku master. When I run this git assumes I am pushing to my Bamboo app, when I really want to deploy to my new Cedar stack.
PhotoRambler tonybeninate$ heroku apps
photoramblr
young-river-1492
young-river-1492 is my new Cedar app, but I have no idea how to deploy to it. Can anyone advise? Thanks.
Or do I need to delete my Bamboo stack first?
No, your .git/config still thinks heroku is your old application. If you crack open that file and edit the heroku remote then it will start pushing to the right place.
have you tried checking how you added your heroku repo for the new app? ie
git remote remove heroku #to remove the link to photoramblr
git remote add heroku git#heroku.com:young-river-1492.git # to add the new one
and then
git push heroku master
You might also want to remove your bamboo app once the new once is up, otherwise you'll need to specify what app for heroku commands ie:
#instead of
heroku rake db:migrate
#you'll have to do
heroku rake db:migrate --app young-river-1492
Check out this tutorial on migrating to the Cedar stack - specifically the part on creating a new Cedar app and deploying. You're on the right track - you just need to specify which app git should push to, since you now have more than once to choose from.
Find out what the remote is called for your new app
>git remote
Push to the new remote
>git push young-river-1492-heroku young-river-1492
You can also rename your remote with git remote rename.
If you prefer, you could edit your config file instead, ala Neil's answer, or edit the config after you've successfully pushed once with the long form to make sure it works.

Resources