Deploy a GitHub branch using heroku CLI
Asked Answered
E

2

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?

Encrinite answered 18/3, 2018 at 14:9 Comment(0)
K
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.)

Koheleth answered 23/8, 2018 at 22:59 Comment(8)
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 configurationEncrinite
@Encrinite Can you provide more details? I'm unclear on what you are looking for / trying to avoid.Koheleth
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.Encrinite
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?Koheleth
yes something like heroku deploy:master -a myappEncrinite
There isn't an out-of-the-box command for that. But you can start a build from the API (which the CLI wraps): devcenter.heroku.com/articles/… 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.Koheleth
Thanks was not aware of the api/plugin system. That can helpEncrinite
As far as I know, heroku CLI tool cannot do this, but the slack integration can. devcenter.heroku.com/articles/chatops#deploying-code-to-an-appPrindle
S
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:[email protected]/repos/<username>/<repo name>/tarball/master/ --app <app-name>

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

Szabadka answered 26/8, 2021 at 10:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.