17

I want to do this action: enter image description here

using Heroku CLI.

If I have the remote git on my computer I can do git push my-heroku-remote master

But because my heroku app is already connected to the git project, I find this approach redundant.

Any ideas?

YardenST
  • 5,119
  • 2
  • 33
  • 54

2 Answers2

2

I prefer the GitHub auto-deployment over the git push heroku master because it works great with a GitHub Flow (Pull Requests to master). But if you would rather do manual deployments to Heroku from your dev machine you can fetch and push:

git fetch origin master:master
git push heroku master:master

(Assuming the GitHub remote is named origin and the Heroku remote is named heroku.)

James Ward
  • 29,283
  • 9
  • 49
  • 85
  • Thanks, but this solves only part of the problem - the machine I'm running this on should be aware of the git project - whereas Heroku is already aware of it. So it's double configuration – YardenST Aug 25 '18 at 10:49
  • @YardenST Can you provide more details? I'm unclear on what you are looking for / trying to avoid. – James Ward Aug 25 '18 at 21:26
  • Yes. We need to assume that the Heroku project has access to the git project. Therefore in theory - I should be able to run only `heroku ...` command that will build the app from the master branch. In your example, however - You are using the git command, which is I wish could be redundant as for my explanation. Because I'd like to have a build process that has not access directly to the git project. – YardenST Aug 26 '18 at 06:50
  • Ok, I think I get it. You want a Heroku CLI equivalent for the manual Deploy GitHub branch button. But you don't want auto-branch deployment. Is that correct? – James Ward Aug 27 '18 at 14:16
  • 4
    yes something like `heroku deploy:master -a myapp` – YardenST Aug 27 '18 at 14:31
  • There isn't an out-of-the-box command for that. But you can start a build from the API (which the CLI wraps): https://devcenter.heroku.com/articles/platform-api-reference#build-create So you could create a Heroku CLI plugin that would do this. So overall not trivial and really I'd recommend the branch auto-deployment instead. – James Ward Aug 27 '18 at 15:46
  • Thanks was not aware of the api/plugin system. That can help – YardenST Aug 27 '18 at 18:19
  • 1
    As far as I know, heroku CLI tool cannot do this, but the slack integration can. https://devcenter.heroku.com/articles/chatops#deploying-code-to-an-app – Weihang Jian Feb 01 '21 at 02:27
0

Taken from here:

This can be done with the builds-create Platform API endpoint.

There is a Builds CLI plugin that makes this easier:

heroku builds:create --source-url https://user:token@api.github.com/repos/<username>/<repo name>/tarball/master/ --app <app-name>

Where user is your Github username and token is a Github personal access token (reference)

Qortex
  • 7,087
  • 3
  • 42
  • 59