Circle ci with heroku. Can't push to heroku automatically - ruby-on-rails

I am trying to set up a workflow that pushes to heroku after I push to my main branch on my github repo. I have done this before with a previous project. I copied over the circle.yml file and changed the name of the old app to the new app, but circle ci gets stuck on the line that says " - git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master"
circle.yml
machine:
ruby:
version: 2.1.2
deployment:
production:
branch: master
commands:
- heroku maintenance:on --app my_app_name
- heroku pg:backups capture --app my_app_name
- git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master
- heroku run rake db:migrate --app my_app_name
- heroku maintenance:off --app my_app_name
staging:
branch: staging
commands:
- heroku maintenance:on --app my_app_name
- git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master
- heroku run rake db:migrate --app my_app_name
- heroku maintenance:off --app my_app_name
I'm getting a remote rejected error at the line
- git push git#heroku.com:my_app_name.git $CIRCLE_SHA1:refs/heads/master
I think I'm getting this error because "git#heroku.com:my_app_name.git" may not be correct. How do I find what to put here?

my_app_name should be replaced by whatever app name is being used on Heroku.

Related

Rails 5 - Circle CI - Heroku - Run migrations after deploy

After deploying to Heroku, I want the migrations to run after deployment. Tried following configuration in circle.yml -
deployment:
staging:
branch: <branch_name>
heroku:
appname: <appname
commands:
- heroku run rake db:migrate --app alldaydr:
timeout: 400
- bundle exec rake swagger:docs
commands:
- git push git#heroku.com:<appname> $CIRCLE_SHA1:master
- heroku run rake db:migrate --app <appname>
It deploys successfully but doesn't run migrations. Any help/idea?
Here is my configuration that works below. I have just one commands instruction and run rake migration just after push to Heroku. You can also get a hint of what's happening from the deploy logs on CircleCI.
deployment:
production:
branch: <branch-name>
commands:
- "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
- git push git#heroku.com:<appname> $CIRCLE_SHA1:refs/heads/master
- heroku run rake db:migrate --app <appname>:
timeout: 400 # if your deploys take a long time
- heroku run rake swagger:docs --app <appname>
Refer to CircleCI's documentation for more

How to specify an app's name while running a Heroku command?

I've just run heroku run rails db:migrate to add some new columns to my production tables after git push heroku master but I receive the error
Simons-MBP:gourmet_coffee Simon$ heroku run rake db:migrate
▸ Error: Could not find git remote stagegcl in /Users/Simon/gourmet_coffee
▸ remotes: heroku staging
So it's clearly trying to run on my staging app. How do I change this so it's my production app?
If you have multiple apps for the same project, you can use --app or -a flag to specify the name of the app.
heroku run rails db:migrate --app <the-name-of-your-app>

Database entry not showing up on Heroku

I am developing my first Rails app, and I have made some database entries that are showing up in the development environment, but not in the production environment (Heroku). I have run
git add
git commit
git push origin master
git push heroku master
rake db:migrate
in the terminal.
$ heroku create
$ git push heroku master
After running these commands, to get the application’s database to work, you’ll also have to migrate the production database:
$ heroku run rake db:migrate
$ heroku open
if this doesn't work please show your logs.
you just need to run
heroku run rake db:migrate

Installing ImageMagick Buildpack on Heroku Rails Cedar 14

I am trying to install this 3rd party Heroku buildpack for ImageMagick: https://github.com/ello/heroku-buildpack-imagemagick
I tried running this command:
heroku buildpacks:add https://github.com/ello/heroku-buildpack-imagemagick
Then I repushed my app to the server, and did a restart. The app didn't work. So I tried restarting the dyno using this command:
heroku ps:scale web=1
I get this response, and cannot run the app unless I remove the ImageMagick buildpack:
Scaling dynos... failed ! Couldn't find that formation.
Any idea how I can get ImageMagick properly installed?
I ran into this yesterday. I don't know about your specific instance but in mine, I had added this build pack after my others. It needed to be before.
In addition, I needed to purge the cache. My remote is called production, so I did the following:
heroku plugins:install https://github.com/heroku/heroku-repo.git
heroku repo:purge_cache --remote production
heroku buildpacks:remove https://github.com/ello/heroku-buildpack-imagemagick --remote production
heroku buildpacks:add --index 1 https://github.com/ello/heroku-buildpack-imagemagick --remote production
Then I pushed my repo to --remote production and it worked.

Retrieve Heroku Logs for Specific Remote

I have a Rails 4 app that I push to Heroku from Git. I have a staging remote and a production remote on Heroku. When I run:
$ heroku logs
I get the staging logs. How can I get the production logs?
$ git remote -v
origin some/github/path (fetch)
origin some/github/path (push)
staging git#heroku.com:some-heroku-app.git (fetch)
staging git#heroku.com:some-heroku-app.git (push)
production git#heroku.com:some-other-heroku-app.git (fetch)
production git#heroku.com:some-other-heroku-app.git (push)
Attempts include:
$ heroku logs -s staging
Replace -s with -r. heroku logs -r staging (or production or whatever).
Use the Heroku app name
heroku logs --app my-production-app

Resources